@hyperframes/studio 0.8.224 → 0.8.226

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.
@@ -585,6 +585,8 @@ function parsePreviewCopies(value) {
585
585
  };
586
586
  }
587
587
  var optionalNumber = (n) => typeof n === "number" ? n : void 0;
588
+ var CLOCK_SOURCES = ["audio", "webaudio", "monotonic"];
589
+ var optionalClock = (clock) => CLOCK_SOURCES.find((known) => known === clock);
588
590
  function parsePlaybackHealth(value) {
589
591
  if (typeof value !== "object" || value === null) return null;
590
592
  const extra = value;
@@ -602,6 +604,7 @@ function parsePlaybackHealth(value) {
602
604
  frozenShare: optionalNumber(extra.frozenShare),
603
605
  gapP50Ms: optionalNumber(extra.gapP50Ms),
604
606
  gapP95Ms: optionalNumber(extra.gapP95Ms),
607
+ clockSource: optionalClock(extra.clockSource),
605
608
  mode: "play"
606
609
  };
607
610
  }
@@ -1252,6 +1255,7 @@ function enableInteractiveIframe(player) {
1252
1255
  container?.style.setProperty("pointer-events", "auto");
1253
1256
  iframe?.style.setProperty("pointer-events", "auto");
1254
1257
  }
1258
+ var studioDraws = (wait, loadingUi) => wait && loadingUi !== "host";
1255
1259
  function isPreviewMediaElement(el) {
1256
1260
  const tagName = el.tagName.toLowerCase();
1257
1261
  return tagName === "video" || tagName === "audio";
@@ -1290,7 +1294,8 @@ var Player = forwardRef(
1290
1294
  portrait,
1291
1295
  style,
1292
1296
  suppressLoadingOverlay,
1293
- noLoadTimeout
1297
+ noLoadTimeout,
1298
+ ...host
1294
1299
  }, ref) => {
1295
1300
  const containerRef = useRef(null);
1296
1301
  const loadCountRef = useRef(0);
@@ -1535,11 +1540,13 @@ var Player = forwardRef(
1535
1540
  );
1536
1541
  return () => clearTimeout(timer);
1537
1542
  }, [projectId]);
1538
- const showCompositionOverlay = !suppressLoadingOverlay && !compositionOverlayDeferred && shouldShowCompositionLoadingOverlay(compositionLoading);
1539
- const showAssetOverlay = assetOverlayVisible && !shaderTransitionLoading && !showCompositionOverlay && !previewError;
1543
+ const compositionWaitShown = !suppressLoadingOverlay && !compositionOverlayDeferred && shouldShowCompositionLoadingOverlay(compositionLoading);
1544
+ const assetWaitShown = assetOverlayVisible && !shaderTransitionLoading && !compositionWaitShown && !previewError;
1545
+ const showCompositionOverlay = studioDraws(compositionWaitShown, host.loadingUi);
1546
+ const showAssetOverlay = studioDraws(assetWaitShown, host.loadingUi);
1540
1547
  useEffect2(() => {
1541
- onCompositionLoadingChange?.(showCompositionOverlay || showAssetOverlay);
1542
- }, [onCompositionLoadingChange, showCompositionOverlay, showAssetOverlay]);
1548
+ onCompositionLoadingChange?.(compositionWaitShown || assetWaitShown);
1549
+ }, [onCompositionLoadingChange, compositionWaitShown, assetWaitShown]);
1543
1550
  return /* @__PURE__ */ jsxs(
1544
1551
  "div",
1545
1552
  {
package/dist/index.d.ts CHANGED
@@ -265,6 +265,7 @@ interface PlaybackHealth {
265
265
  frozenShare?: number;
266
266
  gapP50Ms?: number;
267
267
  gapP95Ms?: number;
268
+ clockSource?: "audio" | "webaudio" | "monotonic";
268
269
  mode: "play";
269
270
  }
270
271
  /** What the preview holds, counts and classes only, filled when asked for. */
@@ -2222,6 +2223,7 @@ interface NLEPreviewProps extends Pick<NLEContextValue, "projectId" | "onIframeL
2222
2223
  portrait?: boolean;
2223
2224
  directUrl?: string;
2224
2225
  suppressLoadingOverlay?: boolean;
2226
+ loadingUi?: "studio" | "host";
2225
2227
  onStageRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
2226
2228
  /** Reports the authored composition size measured from the loaded preview. */
2227
2229
  onCompositionSizeChange?: (size: PreviewCompositionSize | null) => void;
package/dist/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  document.documentElement.dataset.theme = "paper";
15
15
  }
16
16
  </script>
17
- <script type="module" crossorigin src="/assets/index-CZI-XmnO.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-BhZkOhf2.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-RUPGNyct.css">
19
19
  </head>
20
20
  <body>
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  whenPreviewBooted,
55
55
  writeStudioUiPreferences,
56
56
  zoomToSelectedClips
57
- } from "./chunk-2PQ3U3LU.js";
57
+ } from "./chunk-CM72ZNGU.js";
58
58
  import {
59
59
  Button,
60
60
  ContextMenu,
@@ -34153,6 +34153,34 @@ function PreviewZoomOverlay({
34153
34153
  ] });
34154
34154
  }
34155
34155
 
34156
+ // src/components/nle/previewStage.ts
34157
+ var PREVIEW_STAGE_INSET_PX = 8;
34158
+ var SHADOW_IFRAME_STYLE = {
34159
+ position: "absolute",
34160
+ inset: 0,
34161
+ visibility: "hidden",
34162
+ clipPath: "inset(100%)",
34163
+ pointerEvents: "none"
34164
+ };
34165
+ function resolvePreviewStageSize(viewportWidth, viewportHeight, compositionSize, portrait, gutterPx = 0, insetPx = PREVIEW_STAGE_INSET_PX) {
34166
+ const availableWidth = Math.max(0, viewportWidth - 2 * (insetPx + gutterPx));
34167
+ const availableHeight = Math.max(0, viewportHeight - 2 * (insetPx + gutterPx));
34168
+ const aspectRatio = compositionSize && compositionSize.width > 0 && compositionSize.height > 0 ? compositionSize.width / compositionSize.height : portrait ? 9 / 16 : 16 / 9;
34169
+ if (availableWidth === 0 || availableHeight === 0) {
34170
+ return { width: 0, height: 0 };
34171
+ }
34172
+ let width = availableWidth;
34173
+ let height = width / aspectRatio;
34174
+ if (height > availableHeight) {
34175
+ height = availableHeight;
34176
+ width = height * aspectRatio;
34177
+ }
34178
+ return {
34179
+ width: toDomPrecision(width),
34180
+ height: toDomPrecision(height)
34181
+ };
34182
+ }
34183
+
34156
34184
  // src/player/hooks/usePreviewFirstFrameTelemetry.ts
34157
34185
  import { useCallback as useCallback46, useRef as useRef53 } from "react";
34158
34186
  function readPreviewComplexity(doc) {
@@ -34305,32 +34333,6 @@ function getPreviewPlayerKey({
34305
34333
  }
34306
34334
  var ZOOM_HUD_TIMEOUT_MS = 1200;
34307
34335
  var ZOOM_SETTLE_MS = 200;
34308
- var PREVIEW_STAGE_INSET_PX = 8;
34309
- var SHADOW_IFRAME_STYLE = {
34310
- position: "absolute",
34311
- inset: 0,
34312
- visibility: "hidden",
34313
- clipPath: "inset(100%)",
34314
- pointerEvents: "none"
34315
- };
34316
- function resolvePreviewStageSize(viewportWidth, viewportHeight, compositionSize, portrait, gutterPx = 0, insetPx = PREVIEW_STAGE_INSET_PX) {
34317
- const availableWidth = Math.max(0, viewportWidth - 2 * (insetPx + gutterPx));
34318
- const availableHeight = Math.max(0, viewportHeight - 2 * (insetPx + gutterPx));
34319
- const aspectRatio = compositionSize && compositionSize.width > 0 && compositionSize.height > 0 ? compositionSize.width / compositionSize.height : portrait ? 9 / 16 : 16 / 9;
34320
- if (availableWidth === 0 || availableHeight === 0) {
34321
- return { width: 0, height: 0 };
34322
- }
34323
- let width = availableWidth;
34324
- let height = width / aspectRatio;
34325
- if (height > availableHeight) {
34326
- height = availableHeight;
34327
- width = height * aspectRatio;
34328
- }
34329
- return {
34330
- width: toDomPrecision(width),
34331
- height: toDomPrecision(height)
34332
- };
34333
- }
34334
34336
  var NLEPreview = memo24(function NLEPreview2({
34335
34337
  projectId,
34336
34338
  iframeRef,
@@ -34345,6 +34347,7 @@ var NLEPreview = memo24(function NLEPreview2({
34345
34347
  portrait,
34346
34348
  directUrl,
34347
34349
  suppressLoadingOverlay,
34350
+ loadingUi,
34348
34351
  onStageRef,
34349
34352
  onCompositionSizeChange,
34350
34353
  fillBox,
@@ -34701,6 +34704,7 @@ var NLEPreview = memo24(function NLEPreview2({
34701
34704
  onPainted: (details) => reportPreviewFirstFrame(slot, details),
34702
34705
  portrait,
34703
34706
  suppressLoadingOverlay,
34707
+ loadingUi,
34704
34708
  style: directUrl?.includes("/components/") ? { position: "absolute", inset: 0, zIndex: 1 } : void 0
34705
34709
  },
34706
34710
  `${activeKey}-${slot.gen}`
package/dist/player.d.ts CHANGED
@@ -16,6 +16,7 @@ interface PlayerProps {
16
16
  portrait?: boolean;
17
17
  style?: React.CSSProperties;
18
18
  suppressLoadingOverlay?: boolean;
19
+ loadingUi?: "studio" | "host";
19
20
  noLoadTimeout?: boolean;
20
21
  }
21
22
  /**
package/dist/player.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Player
3
- } from "./chunk-2PQ3U3LU.js";
3
+ } from "./chunk-CM72ZNGU.js";
4
4
  import "./chunk-7HZGKFFU.js";
5
5
  import "./chunk-OGIOFEC7.js";
6
6
  import "./chunk-MLKGABMK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.8.224",
3
+ "version": "0.8.226",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,12 +60,12 @@
60
60
  "dockview-react": "8.3.1",
61
61
  "gsap": "^3.13.0",
62
62
  "mediabunny": "^1.45.3",
63
- "@hyperframes/core": "0.8.224",
64
- "@hyperframes/parsers": "0.8.224",
65
- "@hyperframes/player": "0.8.224",
66
- "@hyperframes/shader-transitions": "0.8.224",
67
- "@hyperframes/studio-server": "0.8.224",
68
- "@hyperframes/sdk": "0.8.224"
63
+ "@hyperframes/player": "0.8.226",
64
+ "@hyperframes/core": "0.8.226",
65
+ "@hyperframes/studio-server": "0.8.226",
66
+ "@hyperframes/sdk": "0.8.226",
67
+ "@hyperframes/parsers": "0.8.226",
68
+ "@hyperframes/shader-transitions": "0.8.226"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tailwindcss/vite": "^4.3.3",
@@ -82,7 +82,7 @@
82
82
  "vite": "^6.4.2",
83
83
  "vitest": "^4.1.11",
84
84
  "zustand": "^5.0.0",
85
- "@hyperframes/producer": "0.8.224"
85
+ "@hyperframes/producer": "0.8.226"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -4,7 +4,8 @@ import React, { act, createRef } from "react";
4
4
  import { createRoot } from "react-dom/client";
5
5
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
6
  import { useTimelinePlayer } from "../../player/hooks/useTimelinePlayer";
7
- import { NLEPreview, getPreviewPlayerKey, resolvePreviewStageSize } from "./NLEPreview";
7
+ import { NLEPreview, getPreviewPlayerKey } from "./NLEPreview";
8
+ import { resolvePreviewStageSize } from "./previewStage";
8
9
  import { readPreviewComplexity } from "../../player/hooks/usePreviewFirstFrameTelemetry";
9
10
 
10
11
  globalThis.IS_REACT_ACT_ENVIRONMENT = true;
@@ -28,6 +28,11 @@ import {
28
28
  } from "./previewZoom";
29
29
  import { RULER_GUTTER_PX, usePreviewGuidesStore } from "../editor/previewGuidesStore";
30
30
  import { PreviewZoomOverlay, usePreviewNavigator } from "./PreviewZoomOverlay";
31
+ import {
32
+ PREVIEW_STAGE_INSET_PX,
33
+ resolvePreviewStageSize,
34
+ SHADOW_IFRAME_STYLE,
35
+ } from "./previewStage";
31
36
  import { usePreviewFirstFrameTelemetry } from "../../player/hooks/usePreviewFirstFrameTelemetry";
32
37
  import { PreviewPoster, usePreviewPoster } from "./PreviewPoster";
33
38
  interface NLEPreviewProps extends Pick<
@@ -46,6 +51,7 @@ interface NLEPreviewProps extends Pick<
46
51
  portrait?: boolean;
47
52
  directUrl?: string;
48
53
  suppressLoadingOverlay?: boolean;
54
+ loadingUi?: "studio" | "host";
49
55
  onStageRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
50
56
  /** Reports the authored composition size measured from the loaded preview. */
51
57
  onCompositionSizeChange?: (size: PreviewCompositionSize | null) => void;
@@ -66,51 +72,6 @@ export function getPreviewPlayerKey({
66
72
 
67
73
  const ZOOM_HUD_TIMEOUT_MS = 1200;
68
74
  const ZOOM_SETTLE_MS = 200;
69
- const PREVIEW_STAGE_INSET_PX = 8;
70
-
71
- // clip-path as well as visibility: the player's loading overlay sets its own
72
- // visibility:visible and would otherwise paint over the live frame.
73
- const SHADOW_IFRAME_STYLE: React.CSSProperties = {
74
- position: "absolute",
75
- inset: 0,
76
- visibility: "hidden",
77
- clipPath: "inset(100%)",
78
- pointerEvents: "none",
79
- };
80
-
81
- export function resolvePreviewStageSize(
82
- viewportWidth: number,
83
- viewportHeight: number,
84
- compositionSize: PreviewCompositionSize | null,
85
- portrait: boolean | undefined,
86
- gutterPx = 0,
87
- insetPx = PREVIEW_STAGE_INSET_PX,
88
- ): { width: number; height: number } {
89
- const availableWidth = Math.max(0, viewportWidth - 2 * (insetPx + gutterPx));
90
- const availableHeight = Math.max(0, viewportHeight - 2 * (insetPx + gutterPx));
91
- const aspectRatio =
92
- compositionSize && compositionSize.width > 0 && compositionSize.height > 0
93
- ? compositionSize.width / compositionSize.height
94
- : portrait
95
- ? 9 / 16
96
- : 16 / 9;
97
-
98
- if (availableWidth === 0 || availableHeight === 0) {
99
- return { width: 0, height: 0 };
100
- }
101
-
102
- let width = availableWidth;
103
- let height = width / aspectRatio;
104
- if (height > availableHeight) {
105
- height = availableHeight;
106
- width = height * aspectRatio;
107
- }
108
-
109
- return {
110
- width: toDomPrecision(width),
111
- height: toDomPrecision(height),
112
- };
113
- }
114
75
 
115
76
  export const NLEPreview = memo(function NLEPreview({
116
77
  projectId,
@@ -126,6 +87,7 @@ export const NLEPreview = memo(function NLEPreview({
126
87
  portrait,
127
88
  directUrl,
128
89
  suppressLoadingOverlay,
90
+ loadingUi,
129
91
  onStageRef,
130
92
  onCompositionSizeChange,
131
93
  fillBox,
@@ -544,6 +506,7 @@ export const NLEPreview = memo(function NLEPreview({
544
506
  onPainted={(details) => reportPreviewFirstFrame(slot, details)}
545
507
  portrait={portrait}
546
508
  suppressLoadingOverlay={suppressLoadingOverlay}
509
+ loadingUi={loadingUi}
547
510
  style={
548
511
  directUrl?.includes("/components/")
549
512
  ? { position: "absolute", inset: 0, zIndex: 1 }
@@ -0,0 +1,49 @@
1
+ import type { CSSProperties } from "react";
2
+ import type { PreviewCompositionSize } from "../../utils/previewCompositionSize";
3
+ import { toDomPrecision } from "./previewZoom";
4
+
5
+ export const PREVIEW_STAGE_INSET_PX = 8;
6
+
7
+ // clip-path as well as visibility: the player's loading overlay sets its own
8
+ // visibility:visible and would otherwise paint over the live frame.
9
+ export const SHADOW_IFRAME_STYLE: CSSProperties = {
10
+ position: "absolute",
11
+ inset: 0,
12
+ visibility: "hidden",
13
+ clipPath: "inset(100%)",
14
+ pointerEvents: "none",
15
+ };
16
+
17
+ export function resolvePreviewStageSize(
18
+ viewportWidth: number,
19
+ viewportHeight: number,
20
+ compositionSize: PreviewCompositionSize | null,
21
+ portrait: boolean | undefined,
22
+ gutterPx = 0,
23
+ insetPx = PREVIEW_STAGE_INSET_PX,
24
+ ): { width: number; height: number } {
25
+ const availableWidth = Math.max(0, viewportWidth - 2 * (insetPx + gutterPx));
26
+ const availableHeight = Math.max(0, viewportHeight - 2 * (insetPx + gutterPx));
27
+ const aspectRatio =
28
+ compositionSize && compositionSize.width > 0 && compositionSize.height > 0
29
+ ? compositionSize.width / compositionSize.height
30
+ : portrait
31
+ ? 9 / 16
32
+ : 16 / 9;
33
+
34
+ if (availableWidth === 0 || availableHeight === 0) {
35
+ return { width: 0, height: 0 };
36
+ }
37
+
38
+ let width = availableWidth;
39
+ let height = width / aspectRatio;
40
+ if (height > availableHeight) {
41
+ height = availableHeight;
42
+ width = height * aspectRatio;
43
+ }
44
+
45
+ return {
46
+ width: toDomPrecision(width),
47
+ height: toDomPrecision(height),
48
+ };
49
+ }
@@ -379,6 +379,39 @@ describe("ready to show", () => {
379
379
  expect(usePlayerStore.getState().previewBooted).toBe(true);
380
380
  });
381
381
 
382
+ /** A first load whose one audio has no data yet: Studio's asset wait. */
383
+ async function loadWithUnloadedMedia(props: Partial<PlayerProps>) {
384
+ const { host, player } = await mountPlayer(props);
385
+ const el = player as TestHyperframesPlayer;
386
+ document.body.appendChild(el.iframeElement);
387
+ const doc = el.iframeElement.contentDocument!;
388
+ const audio = doc.createElement("audio");
389
+ Object.defineProperty(audio, "readyState", { value: 0, configurable: true });
390
+ Object.defineProperty(audio, "networkState", { value: 2, configurable: true });
391
+ doc.body.appendChild(audio);
392
+ loadAndReady(el);
393
+ painted(el);
394
+ await flushEffects();
395
+ return host;
396
+ }
397
+
398
+ it("keeps its asset wait on a later load that only skips the composition cover", async () => {
399
+ const host = await loadWithUnloadedMedia({ suppressLoadingOverlay: true });
400
+ expect(host.textContent).toContain("Preparing preview assets");
401
+ });
402
+
403
+ it("draws no loader of its own when the host draws one, and still says the preview is loading", async () => {
404
+ const onCompositionLoadingChange = vi.fn();
405
+ const host = await loadWithUnloadedMedia({
406
+ suppressLoadingOverlay: false,
407
+ loadingUi: "host",
408
+ onCompositionLoadingChange,
409
+ });
410
+ expect(host.textContent).not.toContain("Preparing preview assets");
411
+ expect(host.textContent).not.toContain("Loading composition");
412
+ expect(onCompositionLoadingChange).toHaveBeenLastCalledWith(true);
413
+ });
414
+
382
415
  it("stops deferring editing work when the preview never shows", async () => {
383
416
  vi.useFakeTimers();
384
417
  try {
@@ -37,6 +37,7 @@ interface PlayerProps {
37
37
  portrait?: boolean;
38
38
  style?: React.CSSProperties;
39
39
  suppressLoadingOverlay?: boolean;
40
+ loadingUi?: "studio" | "host";
40
41
  noLoadTimeout?: boolean;
41
42
  }
42
43
 
@@ -88,6 +89,9 @@ function enableInteractiveIframe(player: HyperframesPlayerElement): void {
88
89
  iframe?.style.setProperty("pointer-events", "auto");
89
90
  }
90
91
 
92
+ const studioDraws = (wait: boolean, loadingUi: PlayerProps["loadingUi"]) =>
93
+ wait && loadingUi !== "host";
94
+
91
95
  function isPreviewMediaElement(el: Element): el is HTMLMediaElement {
92
96
  const tagName = el.tagName.toLowerCase();
93
97
  return tagName === "video" || tagName === "audio";
@@ -156,6 +160,7 @@ export const Player = forwardRef<HTMLIFrameElement, PlayerProps>(
156
160
  style,
157
161
  suppressLoadingOverlay,
158
162
  noLoadTimeout,
163
+ ...host
159
164
  },
160
165
  ref,
161
166
  ) => {
@@ -470,16 +475,18 @@ export const Player = forwardRef<HTMLIFrameElement, PlayerProps>(
470
475
  return () => clearTimeout(timer);
471
476
  }, [projectId]);
472
477
 
473
- const showCompositionOverlay =
478
+ const compositionWaitShown =
474
479
  !suppressLoadingOverlay &&
475
480
  !compositionOverlayDeferred &&
476
481
  shouldShowCompositionLoadingOverlay(compositionLoading);
477
- const showAssetOverlay =
478
- assetOverlayVisible && !shaderTransitionLoading && !showCompositionOverlay && !previewError;
482
+ const assetWaitShown =
483
+ assetOverlayVisible && !shaderTransitionLoading && !compositionWaitShown && !previewError;
484
+ const showCompositionOverlay = studioDraws(compositionWaitShown, host.loadingUi);
485
+ const showAssetOverlay = studioDraws(assetWaitShown, host.loadingUi);
479
486
 
480
487
  useEffect(() => {
481
- onCompositionLoadingChange?.(showCompositionOverlay || showAssetOverlay);
482
- }, [onCompositionLoadingChange, showCompositionOverlay, showAssetOverlay]);
488
+ onCompositionLoadingChange?.(compositionWaitShown || assetWaitShown);
489
+ }, [onCompositionLoadingChange, compositionWaitShown, assetWaitShown]);
483
490
 
484
491
  return (
485
492
  <div
@@ -3,7 +3,7 @@
3
3
  import { describe, expect, it } from "vitest";
4
4
  import { usePlayerStore } from "./playerStore";
5
5
  import { readStudioUiPreferences } from "../../utils/studioUiPreferences";
6
- import { parsePreviewCopies } from "./previewQualitySlice";
6
+ import { parsePlaybackHealth, parsePreviewCopies } from "./previewQualitySlice";
7
7
 
8
8
  describe("preview quality in the player store", () => {
9
9
  it("starts at full quality with no copies, and counts retries", () => {
@@ -69,4 +69,22 @@ describe("preview quality in the player store", () => {
69
69
  expect(parsePreviewCopies({ total: "2", ready: 1, failed: 0, progress: 0 })).toBeNull();
70
70
  expect(parsePreviewCopies({ total: 2, ready: 1, failed: 0 })).toBeNull();
71
71
  });
72
+
73
+ it("keeps the clock the runtime names, and only a clock it knows", () => {
74
+ const health = {
75
+ droppedShare: 0.4,
76
+ seconds: 3,
77
+ choppy: true,
78
+ fps: 40,
79
+ worstFrameMs: 90,
80
+ mode: "play",
81
+ };
82
+ expect(parsePlaybackHealth({ ...health, clockSource: "webaudio" })?.clockSource).toBe(
83
+ "webaudio",
84
+ );
85
+ expect(
86
+ parsePlaybackHealth({ ...health, clockSource: "/Users/a/film.mp3" })?.clockSource,
87
+ ).toBeUndefined();
88
+ expect(parsePlaybackHealth(health)?.clockSource).toBeUndefined();
89
+ });
72
90
  });
@@ -24,6 +24,7 @@ export interface PlaybackHealth {
24
24
  frozenShare?: number;
25
25
  gapP50Ms?: number;
26
26
  gapP95Ms?: number;
27
+ clockSource?: "audio" | "webaudio" | "monotonic";
27
28
  mode: "play";
28
29
  }
29
30
 
@@ -115,6 +116,8 @@ export function parsePreviewCopies(value: unknown): PreviewCopies | null {
115
116
  }
116
117
 
117
118
  const optionalNumber = (n: unknown) => (typeof n === "number" ? n : undefined);
119
+ const CLOCK_SOURCES = ["audio", "webaudio", "monotonic"] as const;
120
+ const optionalClock = (clock: unknown) => CLOCK_SOURCES.find((known) => known === clock);
118
121
 
119
122
  export function parsePlaybackHealth(value: unknown): PlaybackHealth | null {
120
123
  if (typeof value !== "object" || value === null) return null;
@@ -133,6 +136,7 @@ export function parsePlaybackHealth(value: unknown): PlaybackHealth | null {
133
136
  frozenShare: optionalNumber(extra.frozenShare),
134
137
  gapP50Ms: optionalNumber(extra.gapP50Ms),
135
138
  gapP95Ms: optionalNumber(extra.gapP95Ms),
139
+ clockSource: optionalClock(extra.clockSource),
136
140
  mode: "play",
137
141
  };
138
142
  }