@hyperframes/studio 0.8.206 → 0.8.207

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.
Files changed (38) hide show
  1. package/dist/assets/hyperframes-player-Cm5aBiKq.js +478 -0
  2. package/dist/assets/{index-CwreIGoq.js → index-BF9YeBnC.js} +131 -131
  3. package/dist/assets/{index-BNuxGFZK.js → index-BrqAmMRt.js} +1 -1
  4. package/dist/{chunk-DAZTBGYM.js → chunk-HPIJDMWG.js} +4 -4
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.html +1 -1
  7. package/dist/index.js +144 -51
  8. package/dist/player.js +1 -1
  9. package/package.json +8 -8
  10. package/src/hooks/timelineEditingHelpers.test.ts +59 -0
  11. package/src/hooks/timelineEditingHelpers.ts +4 -5
  12. package/src/hooks/useGestureRecording.ts +5 -3
  13. package/src/player/components/PlayerControls.tsx +5 -2
  14. package/src/player/components/ShortcutsPanel.tsx +4 -2
  15. package/src/player/components/Timeline.test.ts +12 -0
  16. package/src/player/components/TimelineProvider.tsx +1 -0
  17. package/src/player/components/TimelineRuler.tsx +4 -7
  18. package/src/player/components/TimelineRulerPart.tsx +1 -0
  19. package/src/player/components/timelineClipDragPreview.test.ts +10 -0
  20. package/src/player/components/timelineClipDragPreview.ts +4 -5
  21. package/src/player/components/timelineRulerGeometry.ts +14 -3
  22. package/src/player/components/useTimelineClipDrag.ts +5 -2
  23. package/src/player/components/useTimelineProviderState.tsx +2 -1
  24. package/src/player/components/useTimelineTicks.ts +4 -1
  25. package/src/player/hooks/usePlaybackKeyboard.test.ts +19 -0
  26. package/src/player/hooks/usePlaybackKeyboard.ts +5 -2
  27. package/src/player/hooks/useShadowPreviewReload.ts +4 -1
  28. package/src/player/hooks/useTimelinePlayer.shadowReload.test.ts +21 -0
  29. package/src/player/lib/mediaFetch.test.ts +163 -0
  30. package/src/player/lib/mediaFetch.ts +98 -0
  31. package/src/player/lib/mediaProbe.test.ts +21 -1
  32. package/src/player/lib/mediaProbe.ts +4 -2
  33. package/src/player/lib/thumbnailVideoDecoder.test.ts +24 -1
  34. package/src/player/lib/thumbnailVideoDecoder.ts +3 -1
  35. package/src/player/lib/time.test.ts +13 -13
  36. package/src/player/lib/time.ts +4 -4
  37. package/src/utils/linkedClipPreferences.ts +2 -0
  38. package/dist/assets/hyperframes-player-lCVwx9d3.js +0 -478
@@ -8,16 +8,22 @@ import {
8
8
  probeMissingSourceDurations,
9
9
  resetMediaProbeRegistry,
10
10
  } from "./mediaProbe";
11
+ import { MediaFetchError } from "./mediaFetch";
11
12
 
12
13
  const dispose = vi.fn();
13
14
  const getDurationFromMetadata = vi.fn(async () => 5);
14
15
  const requestedSources: string[] = [];
16
+ const sourceRetryRules: string[] = [];
15
17
 
16
18
  vi.mock("mediabunny", () => ({
17
19
  ALL_FORMATS: {},
18
20
  UrlSource: class {
19
- constructor(readonly url: string) {
21
+ constructor(
22
+ readonly url: string,
23
+ readonly options?: { getRetryDelay?: unknown },
24
+ ) {
20
25
  requestedSources.push(url);
26
+ sourceRetryRules.push(typeof options?.getRetryDelay);
21
27
  }
22
28
  },
23
29
  Input: class {
@@ -32,6 +38,7 @@ beforeEach(() => {
32
38
  resetMediaProbeRegistry();
33
39
  vi.clearAllMocks();
34
40
  requestedSources.length = 0;
41
+ sourceRetryRules.length = 0;
35
42
  getDurationFromMetadata.mockResolvedValue(5);
36
43
  });
37
44
 
@@ -40,6 +47,19 @@ afterEach(() => {
40
47
  });
41
48
 
42
49
  describe("media probe registry", () => {
50
+ it("reports a failed range fetch as one typed line and records the probe as failed", async () => {
51
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
52
+ const failure = new MediaFetchError("probe", 403, null);
53
+ getDurationFromMetadata.mockRejectedValue(failure);
54
+
55
+ await expect(probeMediaUrl("/locked.mp4")).resolves.toBeNull();
56
+ expect(sourceRetryRules).toEqual(["function"]);
57
+ expect(warn.mock.calls).toEqual([
58
+ ["[Studio] probe range fetch failed: HTTP 403 after 0 retries"],
59
+ ]);
60
+ warn.mockRestore();
61
+ });
62
+
43
63
  it("deduplicates and caches successful probes", async () => {
44
64
  const [first, second] = await Promise.all([
45
65
  probeMediaUrl("/video.mp4"),
@@ -1,5 +1,6 @@
1
1
  import { authoredSrcPath, resolveMediaPreviewUrl } from "../components/thumbnailUtils";
2
2
  import { TIMELINE_VIEWPORT_BUDGETS } from "./timelineViewportBudgets";
3
+ import { mediaUrlSourceOptions, reportMediaFetchFailure } from "./mediaFetch";
3
4
 
4
5
  export interface MediaProbeResult {
5
6
  duration: number;
@@ -55,7 +56,7 @@ async function probeOne(url: string): Promise<MediaProbeResult | null> {
55
56
  if (!mb) return null;
56
57
 
57
58
  const input = new mb.Input({
58
- source: new mb.UrlSource(url),
59
+ source: new mb.UrlSource(url, mediaUrlSourceOptions("probe")),
59
60
  formats: mb.ALL_FORMATS,
60
61
  });
61
62
  try {
@@ -73,7 +74,8 @@ async function probeOne(url: string): Promise<MediaProbeResult | null> {
73
74
  hasAudio: audioTracks.length > 0,
74
75
  };
75
76
  return result;
76
- } catch {
77
+ } catch (error) {
78
+ reportMediaFetchFailure(error);
77
79
  return null;
78
80
  } finally {
79
81
  input.dispose();
@@ -2,8 +2,10 @@
2
2
 
3
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
4
4
  import { decodeVideoThumbnail, videoThumbnailTimestamps } from "./thumbnailVideoDecoder";
5
+ import { MediaFetchError } from "./mediaFetch";
5
6
 
6
7
  const dispose = vi.fn();
8
+ const sourceRetryRules: string[] = [];
7
9
  const canvasesAtTimestamps = vi.fn();
8
10
  const getKeyPacket = vi.fn(async (_time: number) => null as { timestamp: number } | null);
9
11
  const input = {
@@ -14,7 +16,12 @@ const input = {
14
16
  vi.mock("mediabunny", () => ({
15
17
  ALL_FORMATS: {},
16
18
  UrlSource: class {
17
- constructor(readonly url: string) {}
19
+ constructor(
20
+ readonly url: string,
21
+ readonly options?: { getRetryDelay?: unknown },
22
+ ) {
23
+ sourceRetryRules.push(typeof options?.getRetryDelay);
24
+ }
18
25
  },
19
26
  Input: class {
20
27
  getPrimaryVideoTrack = input.getPrimaryVideoTrack;
@@ -371,6 +378,22 @@ describe("decodeVideoThumbnail", () => {
371
378
  expect(URL.revokeObjectURL).toHaveBeenCalledTimes(5);
372
379
  });
373
380
 
381
+ it("reports a failed range fetch as one typed line and rethrows it", async () => {
382
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
383
+ sourceRetryRules.length = 0;
384
+ input.getPrimaryVideoTrack.mockRejectedValue(
385
+ new MediaFetchError("thumbnail", null, "TypeError"),
386
+ );
387
+ await expect(
388
+ decodeVideoThumbnail({ source: "/locked.mp4", frameCount: 1 }, new AbortController().signal),
389
+ ).rejects.toBeInstanceOf(MediaFetchError);
390
+ expect(sourceRetryRules).toEqual(["function"]);
391
+ expect(warn.mock.calls).toEqual([
392
+ ["[Studio] thumbnail range fetch failed: network TypeError after 0 retries"],
393
+ ]);
394
+ warn.mockRestore();
395
+ });
396
+
374
397
  it("releases input and degrades when the source has no video track", async () => {
375
398
  input.getPrimaryVideoTrack.mockResolvedValue(null);
376
399
  await expect(
@@ -4,6 +4,7 @@ import {
4
4
  type ThumbnailLoadedResult,
5
5
  type ThumbnailValue,
6
6
  } from "./thumbnailScheduler";
7
+ import { mediaUrlSourceOptions, reportMediaFetchFailure } from "./mediaFetch";
7
8
 
8
9
  export interface VideoThumbnailDecodeRequest {
9
10
  source: string;
@@ -260,6 +261,7 @@ export async function decodeVideoThumbnail(
260
261
  return await decodeMissingFrames(request, signal, budgets, keyOf, resources);
261
262
  } catch (error) {
262
263
  releaseDecodedResources(resources);
264
+ reportMediaFetchFailure(error);
263
265
  throw error;
264
266
  }
265
267
  }
@@ -275,7 +277,7 @@ async function decodeMissingFrames(
275
277
  throwIfAborted(signal);
276
278
 
277
279
  const input = new mediabunny.Input({
278
- source: new mediabunny.UrlSource(request.source),
280
+ source: new mediabunny.UrlSource(request.source, mediaUrlSourceOptions("thumbnail")),
279
281
  formats: mediabunny.ALL_FORMATS,
280
282
  });
281
283
  try {
@@ -58,29 +58,29 @@ describe("formatTime", () => {
58
58
  });
59
59
 
60
60
  describe("frame helpers", () => {
61
- it("converts seconds to frames at the Studio preview rate", () => {
62
- expect(secondsToFrame(0)).toBe(0);
63
- expect(secondsToFrame(1)).toBe(30);
64
- expect(secondsToFrame(1.5)).toBe(45);
61
+ it("converts seconds to frames at 30 fps", () => {
62
+ expect(secondsToFrame(0, 30)).toBe(0);
63
+ expect(secondsToFrame(1, 30)).toBe(30);
64
+ expect(secondsToFrame(1.5, 30)).toBe(45);
65
65
  });
66
66
 
67
- it("converts frames to seconds at the Studio preview rate", () => {
68
- expect(frameToSeconds(0)).toBe(0);
69
- expect(frameToSeconds(30)).toBe(1);
70
- expect(frameToSeconds(45)).toBe(1.5);
67
+ it("converts frames to seconds at 30 fps", () => {
68
+ expect(frameToSeconds(0, 30)).toBe(0);
69
+ expect(frameToSeconds(30, 30)).toBe(1);
70
+ expect(frameToSeconds(45, 30)).toBe(1.5);
71
71
  });
72
72
 
73
73
  it("formats current and total frame display", () => {
74
- expect(formatFrameTime(1, 5)).toBe("30f / 150f");
74
+ expect(formatFrameTime(1, 5, 30)).toBe("30f / 150f");
75
75
  });
76
76
 
77
77
  it("steps from a truncated runtime time by integer frame index", () => {
78
- expect(stepFrameTime(0.0333333, 1)).toBe(2 / 30);
79
- expect(stepFrameTime(0.0666666, 1)).toBe(3 / 30);
80
- expect(stepFrameTime(0.0666666, -1)).toBe(1 / 30);
78
+ expect(stepFrameTime(0.0333333, 1, 30)).toBe(2 / 30);
79
+ expect(stepFrameTime(0.0666666, 1, 30)).toBe(3 / 30);
80
+ expect(stepFrameTime(0.0666666, -1, 30)).toBe(1 / 30);
81
81
  });
82
82
 
83
83
  it("clamps frame stepping at zero", () => {
84
- expect(stepFrameTime(0, -1)).toBe(0);
84
+ expect(stepFrameTime(0, -1, 30)).toBe(0);
85
85
  });
86
86
  });
@@ -14,25 +14,25 @@ export function formatTime(time: number): string {
14
14
  return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
15
15
  }
16
16
 
17
- export function secondsToFrame(time: number, fps = STUDIO_PREVIEW_FPS): number {
17
+ export function secondsToFrame(time: number, fps: number): number {
18
18
  if (!Number.isFinite(time) || time <= 0) return 0;
19
19
  if (!Number.isFinite(fps) || fps <= 0) return 0;
20
20
  return Math.round(time * fps);
21
21
  }
22
22
 
23
- export function frameToSeconds(frame: number, fps = STUDIO_PREVIEW_FPS): number {
23
+ export function frameToSeconds(frame: number, fps: number): number {
24
24
  if (!Number.isFinite(frame) || frame <= 0) return 0;
25
25
  if (!Number.isFinite(fps) || fps <= 0) return 0;
26
26
  return frame / fps;
27
27
  }
28
28
 
29
- export function stepFrameTime(time: number, deltaFrames: number, fps = STUDIO_PREVIEW_FPS): number {
29
+ export function stepFrameTime(time: number, deltaFrames: number, fps: number): number {
30
30
  const currentFrame = secondsToFrame(time, fps);
31
31
  const nextFrame = Math.max(0, currentFrame + deltaFrames);
32
32
  return frameToSeconds(nextFrame, fps);
33
33
  }
34
34
 
35
- export function formatFrameTime(time: number, duration: number, fps = STUDIO_PREVIEW_FPS): string {
35
+ export function formatFrameTime(time: number, duration: number, fps: number): string {
36
36
  const currentFrame = secondsToFrame(time, fps);
37
37
  const totalFrames = secondsToFrame(duration, fps);
38
38
  return `${currentFrame}f / ${totalFrames}f`;
@@ -30,5 +30,7 @@ export const useLinkedClipPreferences = create<LinkedClipPreferences>((set) => (
30
30
  },
31
31
  }));
32
32
 
33
+ export const useCompositionFps = (): number => useLinkedClipPreferences((s) => s.compositionFps);
34
+
33
35
  export const isLinkedSelectionOn = (): boolean =>
34
36
  useLinkedClipPreferences.getState().linkedSelection;