@hyperframes/studio 0.8.206 → 0.8.208

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-5dRdMVOq.js +478 -0
  2. package/dist/assets/{index-CwreIGoq.js → index-Bu3mJUU2.js} +131 -131
  3. package/dist/assets/{index-BNuxGFZK.js → index-ZqyQ91pm.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
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-CwreIGoq.js";/*!
1
+ import{n as Qi}from"./index-Bu3mJUU2.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -16,22 +16,22 @@ function formatTime(time) {
16
16
  const secs = Math.floor(time % 60);
17
17
  return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
18
18
  }
19
- function secondsToFrame(time, fps = STUDIO_PREVIEW_FPS) {
19
+ function secondsToFrame(time, fps) {
20
20
  if (!Number.isFinite(time) || time <= 0) return 0;
21
21
  if (!Number.isFinite(fps) || fps <= 0) return 0;
22
22
  return Math.round(time * fps);
23
23
  }
24
- function frameToSeconds(frame, fps = STUDIO_PREVIEW_FPS) {
24
+ function frameToSeconds(frame, fps) {
25
25
  if (!Number.isFinite(frame) || frame <= 0) return 0;
26
26
  if (!Number.isFinite(fps) || fps <= 0) return 0;
27
27
  return frame / fps;
28
28
  }
29
- function stepFrameTime(time, deltaFrames, fps = STUDIO_PREVIEW_FPS) {
29
+ function stepFrameTime(time, deltaFrames, fps) {
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
- function formatFrameTime(time, duration, fps = STUDIO_PREVIEW_FPS) {
34
+ function formatFrameTime(time, duration, fps) {
35
35
  const currentFrame = secondsToFrame(time, fps);
36
36
  const totalFrames = secondsToFrame(duration, fps);
37
37
  return `${currentFrame}f / ${totalFrames}f`;
package/dist/index.d.ts CHANGED
@@ -1735,6 +1735,7 @@ type TimelineCanvasState = Omit<TimelineLaneBaseProps, "setRangeSelection" | "se
1735
1735
  totalH: number;
1736
1736
  effectiveDuration: number;
1737
1737
  majorTickInterval: number;
1738
+ tickFrameRate: number | undefined;
1738
1739
  rangeSelection: TimelineRangeSelection | null;
1739
1740
  marqueeRect: Rect$1 | null;
1740
1741
  resizingClip: ResizingClipState | null;
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-CwreIGoq.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-Bu3mJUU2.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-CYbvOVp-.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-DAZTBGYM.js";
57
+ } from "./chunk-HPIJDMWG.js";
58
58
  import {
59
59
  Button,
60
60
  ContextMenu,
@@ -598,6 +598,27 @@ if (typeof window !== "undefined") {
598
598
  });
599
599
  }
600
600
 
601
+ // src/utils/linkedClipPreferences.ts
602
+ import { create } from "zustand";
603
+ var useLinkedClipPreferences = create((set) => ({
604
+ linkedSelection: readStudioUiPreferences().linkedSelectionEnabled ?? true,
605
+ setLinkedSelection: (enabled) => {
606
+ writeStudioUiPreferences({ linkedSelectionEnabled: enabled });
607
+ set({ linkedSelection: enabled });
608
+ },
609
+ syncIndicatorsVisible: readStudioUiPreferences().syncIndicatorsVisible ?? true,
610
+ setSyncIndicatorsVisible: (visible) => {
611
+ writeStudioUiPreferences({ syncIndicatorsVisible: visible });
612
+ set({ syncIndicatorsVisible: visible });
613
+ },
614
+ compositionFps: STUDIO_PREVIEW_FPS,
615
+ setCompositionFps: (fps) => {
616
+ if (Number.isFinite(fps) && fps > 0) set({ compositionFps: fps });
617
+ }
618
+ }));
619
+ var useCompositionFps = () => useLinkedClipPreferences((s) => s.compositionFps);
620
+ var isLinkedSelectionOn = () => useLinkedClipPreferences.getState().linkedSelection;
621
+
601
622
  // src/player/components/ShortcutsPanel.tsx
602
623
  import { useState, useCallback, useRef, memo } from "react";
603
624
 
@@ -722,13 +743,14 @@ var ShortcutsPanel = memo(function ShortcutsPanel2({
722
743
  }) {
723
744
  const [showShortcuts, setShowShortcuts] = useState(false);
724
745
  const [jumpFrame, setJumpFrame] = useState("");
746
+ const compositionFps2 = useCompositionFps();
725
747
  const panelBodyRef = useRef(null);
726
748
  const commitJumpFrame = useCallback(() => {
727
749
  if (disabled) return;
728
750
  const frame3 = Number.parseInt(jumpFrame, 10);
729
751
  if (!Number.isFinite(frame3) || duration <= 0) return;
730
- onSeek(Math.min(duration, frameToSeconds(Math.max(0, frame3))));
731
- }, [disabled, duration, jumpFrame, onSeek]);
752
+ onSeek(Math.min(duration, frameToSeconds(Math.max(0, frame3), compositionFps2)));
753
+ }, [compositionFps2, disabled, duration, jumpFrame, onSeek]);
732
754
  const handleJumpSubmit = useCallback(
733
755
  (e) => {
734
756
  e.preventDefault();
@@ -1235,6 +1257,7 @@ var FullscreenButton = memo5(function FullscreenButton2({
1235
1257
  }
1236
1258
  ) });
1237
1259
  });
1260
+ var compositionFps = () => useLinkedClipPreferences.getState().compositionFps;
1238
1261
  var PlayerControls = memo5(function PlayerControls2({
1239
1262
  onTogglePlay,
1240
1263
  onSeek,
@@ -1266,14 +1289,14 @@ var PlayerControls = memo5(function PlayerControls2({
1266
1289
  useEffect3(() => {
1267
1290
  if (!timeDisplayRef.current) return;
1268
1291
  const t2 = currentTimeRef.current;
1269
- timeDisplayRef.current.textContent = timeDisplayMode === "frame" ? formatFrameTime(t2, duration) : formatTime(t2);
1292
+ timeDisplayRef.current.textContent = timeDisplayMode === "frame" ? formatFrameTime(t2, duration, compositionFps()) : formatTime(t2);
1270
1293
  }, [duration, timeDisplayMode]);
1271
1294
  useMountEffect(() => {
1272
1295
  const updateTime = (time) => {
1273
1296
  currentTimeRef.current = time;
1274
1297
  if (!timeDisplayRef.current) return;
1275
1298
  const currentDuration = durationRef.current;
1276
- const text = timeDisplayModeRef.current === "frame" ? formatFrameTime(time, currentDuration) : formatTime(time);
1299
+ const text = timeDisplayModeRef.current === "frame" ? formatFrameTime(time, currentDuration, compositionFps()) : formatTime(time);
1277
1300
  if (timeDisplayRef.current.textContent !== text) timeDisplayRef.current.textContent = text;
1278
1301
  };
1279
1302
  const unsubscribe = liveTime.subscribe(updateTime);
@@ -4313,8 +4336,8 @@ function tickSpacing(duration, pixelsPerSecond, frameRate) {
4313
4336
  const subdivisions = getMinorSubdivisions(majorInterval, pixelsPerSecond, frameRate);
4314
4337
  return { majorInterval, subdivisions };
4315
4338
  }
4316
- function rulerFrameRate(mode) {
4317
- return mode === "frame" ? STUDIO_PREVIEW_FPS : void 0;
4339
+ function rulerFrameRate(mode, fps) {
4340
+ return mode === "frame" ? fps : void 0;
4318
4341
  }
4319
4342
  function getTimelineGridStep(duration, pixelsPerSecond, frameRate) {
4320
4343
  if (!isSupportedTickDuration(duration)) return 0;
@@ -4362,10 +4385,13 @@ function formatTimelineTickLabel(time, duration, majorInterval) {
4362
4385
  }
4363
4386
  return formatTime(safeTime);
4364
4387
  }
4388
+ function rulerTickText(time, frameRate, duration, majorInterval) {
4389
+ return frameRate ? secondsToFrame(time, frameRate) : formatTimelineTickLabel(time, duration, majorInterval);
4390
+ }
4365
4391
 
4366
4392
  // src/player/store/previewFrameStore.ts
4367
- import { create } from "zustand";
4368
- var usePreviewFrameStore = create(() => ({ time: null }));
4393
+ import { create as create2 } from "zustand";
4394
+ var usePreviewFrameStore = create2(() => ({ time: null }));
4369
4395
  var setPreviewFrame = (time) => usePreviewFrameStore.setState({ time });
4370
4396
  function showingPreviewFrame(adapter) {
4371
4397
  let seeked = false;
@@ -4770,9 +4796,9 @@ function guideIfSaved(element, clip, target, pps) {
4770
4796
  const off = Math.min(Math.abs(saved2.start - target.time), Math.abs(saved2.end - target.time));
4771
4797
  return off * pps < 1 ? target : null;
4772
4798
  }
4773
- var TRIM_END_FRAME_LEAD_S = 1 / STUDIO_PREVIEW_FPS;
4774
4799
  function trimPreviewTime(edge, start, duration) {
4775
- return edge === "start" ? start : Math.max(start, start + duration - TRIM_END_FRAME_LEAD_S);
4800
+ const frame3 = 1 / useLinkedClipPreferences.getState().compositionFps;
4801
+ return edge === "start" ? start : Math.max(start, start + duration - frame3);
4776
4802
  }
4777
4803
  function computeResizePreview(resize, clientX, ctx3) {
4778
4804
  const { scroll, pps, buildSnapTargets } = ctx3;
@@ -4859,26 +4885,6 @@ function previewGroupResize(session, next, setResizeState) {
4859
4885
  });
4860
4886
  }
4861
4887
 
4862
- // src/utils/linkedClipPreferences.ts
4863
- import { create as create2 } from "zustand";
4864
- var useLinkedClipPreferences = create2((set) => ({
4865
- linkedSelection: readStudioUiPreferences().linkedSelectionEnabled ?? true,
4866
- setLinkedSelection: (enabled) => {
4867
- writeStudioUiPreferences({ linkedSelectionEnabled: enabled });
4868
- set({ linkedSelection: enabled });
4869
- },
4870
- syncIndicatorsVisible: readStudioUiPreferences().syncIndicatorsVisible ?? true,
4871
- setSyncIndicatorsVisible: (visible) => {
4872
- writeStudioUiPreferences({ syncIndicatorsVisible: visible });
4873
- set({ syncIndicatorsVisible: visible });
4874
- },
4875
- compositionFps: STUDIO_PREVIEW_FPS,
4876
- setCompositionFps: (fps) => {
4877
- if (Number.isFinite(fps) && fps > 0) set({ compositionFps: fps });
4878
- }
4879
- }));
4880
- var isLinkedSelectionOn = () => useLinkedClipPreferences.getState().linkedSelection;
4881
-
4882
4888
  // src/player/components/timelineReadOnly.ts
4883
4889
  import { createContext as createContext2, useContext as useContext2, useEffect as useEffect7, useEffectEvent } from "react";
4884
4890
  var TimelineReadOnlyContext = createContext2(null);
@@ -10941,7 +10947,10 @@ function useTimelineClipDrag({
10941
10947
  );
10942
10948
  const snapGridStep = useCallback8(() => {
10943
10949
  if (!snapContextRef.current.enabled) return 0;
10944
- const frameRate = rulerFrameRate(usePlayerStore.getState().timeDisplayMode);
10950
+ const frameRate = rulerFrameRate(
10951
+ usePlayerStore.getState().timeDisplayMode,
10952
+ useLinkedClipPreferences.getState().compositionFps
10953
+ );
10945
10954
  return getTimelineGridStep(durationRef.current, ppsRef.current, frameRate);
10946
10955
  }, [durationRef, ppsRef]);
10947
10956
  const [draggedClip, setDraggedClipState] = useState8(null);
@@ -13976,13 +13985,15 @@ function useTimelineShiftModifier() {
13976
13985
  // src/player/components/useTimelineTicks.ts
13977
13986
  import { useMemo as useMemo18 } from "react";
13978
13987
  function useTimelineTicks(duration, pixelsPerSecond, timeDisplayMode, renderTimeRange) {
13979
- const frameRate = rulerFrameRate(timeDisplayMode);
13988
+ const compositionFps2 = useCompositionFps();
13989
+ const frameRate = rulerFrameRate(timeDisplayMode, compositionFps2);
13980
13990
  const ticks = useMemo18(
13981
13991
  () => generateTicks(duration, pixelsPerSecond, frameRate, renderTimeRange),
13982
13992
  [duration, frameRate, pixelsPerSecond, renderTimeRange]
13983
13993
  );
13984
13994
  return {
13985
13995
  ...ticks,
13996
+ frameRate,
13986
13997
  majorTickInterval: getTimelineMajorTickInterval(duration, pixelsPerSecond, frameRate)
13987
13998
  };
13988
13999
  }
@@ -15036,7 +15047,7 @@ function useTimelineProviderState({
15036
15047
  dragActive: draggedClip?.started === true || resizingClip != null,
15037
15048
  displayDuration
15038
15049
  });
15039
- const { major, minor, majorTickInterval } = useTimelineTicks(
15050
+ const { major, minor, majorTickInterval, frameRate } = useTimelineTicks(
15040
15051
  displayDuration,
15041
15052
  pps,
15042
15053
  timeDisplayMode,
@@ -15052,6 +15063,7 @@ function useTimelineProviderState({
15052
15063
  totalH: displayLayout.totalH,
15053
15064
  effectiveDuration,
15054
15065
  majorTickInterval,
15066
+ tickFrameRate: frameRate,
15055
15067
  rangeSelection,
15056
15068
  marqueeRect,
15057
15069
  laneGapStrips,
@@ -15303,13 +15315,13 @@ var TimelineRuler = memo10(function TimelineRuler2({
15303
15315
  totalH,
15304
15316
  effectiveDuration,
15305
15317
  majorTickInterval,
15318
+ tickFrameRate,
15306
15319
  theme,
15307
15320
  beatAnalysis,
15308
15321
  contentOrigin,
15309
15322
  renderTimeRange,
15310
15323
  scrollRef
15311
15324
  }) {
15312
- const timeDisplayMode = usePlayerStore((s) => s.timeDisplayMode);
15313
15325
  const beatTimes = beatAnalysis?.beatTimes ?? [];
15314
15326
  const beatStrengths = beatAnalysis?.beatStrengths ?? [];
15315
15327
  const beatEntries = getTimelineBeatEntries(beatTimes, beatStrengths, renderTimeRange);
@@ -15401,7 +15413,7 @@ var TimelineRuler = memo10(function TimelineRuler2({
15401
15413
  top: 5,
15402
15414
  fontSize: 10
15403
15415
  },
15404
- children: timeDisplayMode === "frame" ? secondsToFrame(t2) : formatTimelineTickLabel(t2, effectiveDuration, majorTickInterval)
15416
+ children: rulerTickText(t2, tickFrameRate, effectiveDuration, majorTickInterval)
15405
15417
  }
15406
15418
  ),
15407
15419
  /* @__PURE__ */ jsx26("div", { className: "w-px", style: { height: RULER_H, background: theme.tickMajor } })
@@ -15442,6 +15454,7 @@ function TimelineRulerPart() {
15442
15454
  totalH: props.totalH,
15443
15455
  effectiveDuration: props.effectiveDuration,
15444
15456
  majorTickInterval: props.majorTickInterval,
15457
+ tickFrameRate: props.tickFrameRate,
15445
15458
  theme: props.theme,
15446
15459
  beatAnalysis: props.beatAnalysis,
15447
15460
  contentOrigin: props.contentOrigin,
@@ -19025,7 +19038,6 @@ async function persistTimelineEdit(input) {
19025
19038
  if (!patchTarget) {
19026
19039
  throw new Error(`Timeline element ${input.element.id} is missing a patchable target`);
19027
19040
  }
19028
- input.pendingTimelineEditPathRef.current.add(targetPath);
19029
19041
  await saveProjectFilesWithHistory({
19030
19042
  projectId: input.projectId,
19031
19043
  label: input.label,
@@ -19033,10 +19045,10 @@ async function persistTimelineEdit(input) {
19033
19045
  coalesceMs: input.coalesceMs,
19034
19046
  files: {
19035
19047
  [targetPath]: (current) => {
19036
- const patched = input.buildPatches(current, patchTarget);
19037
- if (patched === current) {
19038
- throw new Error(`Unable to patch timeline element ${input.element.id} in ${targetPath}`);
19039
- }
19048
+ const patched = patchTimelineChangesInSource(current, targetPath, [
19049
+ { element: input.element, buildPatches: input.buildPatches }
19050
+ ]);
19051
+ if (patched !== current) input.pendingTimelineEditPathRef.current.add(targetPath);
19040
19052
  return patched;
19041
19053
  }
19042
19054
  },
@@ -28115,6 +28127,77 @@ var Timeline = Object.assign(TimelineComposed, {
28115
28127
  // src/player/components/VideoThumbnail.tsx
28116
28128
  import { memo as memo22, useMemo as useMemo36, useState as useState35 } from "react";
28117
28129
 
28130
+ // src/player/lib/mediaFetch.ts
28131
+ var describe = (reader, status, code, retries) => `${reader} range fetch failed: ${status === null ? `network ${code}` : `HTTP ${status}`} after ${retries} retries`;
28132
+ var MediaFetchError = class extends Error {
28133
+ constructor(reader, status, code) {
28134
+ super(describe(reader, status, code, 0));
28135
+ this.reader = reader;
28136
+ this.status = status;
28137
+ this.code = code;
28138
+ }
28139
+ reader;
28140
+ status;
28141
+ code;
28142
+ name = "MediaFetchError";
28143
+ retries = 0;
28144
+ setRetries(retries) {
28145
+ this.retries = retries;
28146
+ this.message = describe(this.reader, this.status, this.code, retries);
28147
+ }
28148
+ };
28149
+ var MAX_RETRIES = 2;
28150
+ var isAbort = (error) => error?.name === "AbortError";
28151
+ function networkCode(error) {
28152
+ const cause = error?.cause;
28153
+ if (typeof cause?.code === "string") return cause.code;
28154
+ const name = error?.name;
28155
+ return typeof name === "string" ? name : "unknown";
28156
+ }
28157
+ var typedFailure = (reader, error) => isAbort(error) ? error : new MediaFetchError(reader, null, networkCode(error));
28158
+ function typedBody(reader, body) {
28159
+ const source = body.getReader();
28160
+ return new ReadableStream({
28161
+ async pull(controller) {
28162
+ try {
28163
+ const { done, value } = await source.read();
28164
+ if (done) controller.close();
28165
+ else controller.enqueue(value);
28166
+ } catch (error) {
28167
+ controller.error(typedFailure(reader, error));
28168
+ }
28169
+ },
28170
+ cancel: (reason) => source.cancel(reason)
28171
+ });
28172
+ }
28173
+ function mediaUrlSourceOptions(reader) {
28174
+ let failures = 0;
28175
+ const fetchFn = async (input, init) => {
28176
+ let response;
28177
+ try {
28178
+ response = await fetch(input, init);
28179
+ } catch (error) {
28180
+ throw typedFailure(reader, error);
28181
+ }
28182
+ if (!response.ok) throw new MediaFetchError(reader, response.status, null);
28183
+ if (!response.body) return response;
28184
+ const { status, statusText, headers } = response;
28185
+ return new Response(typedBody(reader, response.body), { status, statusText, headers });
28186
+ };
28187
+ const getRetryDelay = (_previousAttempts, error) => {
28188
+ const clientError = error instanceof MediaFetchError && error.status !== null && error.status < 500;
28189
+ if (error instanceof MediaFetchError) error.setRetries(failures);
28190
+ if (clientError || failures >= MAX_RETRIES) return null;
28191
+ failures++;
28192
+ return 0.5 * failures;
28193
+ };
28194
+ return { fetchFn, getRetryDelay };
28195
+ }
28196
+ function reportMediaFetchFailure(error) {
28197
+ if (!(error instanceof MediaFetchError)) return;
28198
+ console.warn(`[Studio] ${error.message}`);
28199
+ }
28200
+
28118
28201
  // src/player/lib/thumbnailVideoDecoder.ts
28119
28202
  var LAST_FRAME_INSET_S = 1e-3;
28120
28203
  function videoThumbnailTimestamps(start, duration, frameCount) {
@@ -28277,6 +28360,7 @@ async function decodeVideoThumbnail(request2, signal, budgets = TIMELINE_VIEWPOR
28277
28360
  return await decodeMissingFrames(request2, signal, budgets, keyOf17, resources);
28278
28361
  } catch (error) {
28279
28362
  releaseDecodedResources(resources);
28363
+ reportMediaFetchFailure(error);
28280
28364
  throw error;
28281
28365
  }
28282
28366
  }
@@ -28284,7 +28368,7 @@ async function decodeMissingFrames(request2, signal, budgets, keyOf17, resources
28284
28368
  const mediabunny = await import("mediabunny");
28285
28369
  throwIfAborted(signal);
28286
28370
  const input = new mediabunny.Input({
28287
- source: new mediabunny.UrlSource(request2.source),
28371
+ source: new mediabunny.UrlSource(request2.source, mediaUrlSourceOptions("thumbnail")),
28288
28372
  formats: mediabunny.ALL_FORMATS
28289
28373
  });
28290
28374
  try {
@@ -29023,7 +29107,9 @@ function usePlaybackKeyboard({
29023
29107
  (deltaFrames) => {
29024
29108
  const adapter = getAdapter();
29025
29109
  const currentTime = adapter?.getTime() ?? usePlayerStore.getState().currentTime;
29026
- seek(stepFrameTime(currentTime, deltaFrames, STUDIO_PREVIEW_FPS));
29110
+ seek(
29111
+ stepFrameTime(currentTime, deltaFrames, useLinkedClipPreferences.getState().compositionFps)
29112
+ );
29027
29113
  },
29028
29114
  [getAdapter, seek]
29029
29115
  );
@@ -31553,6 +31639,9 @@ function applyStudioRotation(element, rotation) {
31553
31639
  );
31554
31640
  }
31555
31641
 
31642
+ // src/player/hooks/useShadowPreviewReload.ts
31643
+ import { refusedPreviewStatus } from "@hyperframes/core/studio-preview-mark";
31644
+
31556
31645
  // src/utils/studioDebug.ts
31557
31646
  function makeStudioDebugLogger(name) {
31558
31647
  let enabled = null;
@@ -31693,7 +31782,9 @@ function useShadowPreviewReload({
31693
31782
  setPreviewReloading(false);
31694
31783
  const message = `The preview did not reload (${cause}). It was still waiting for ${waitingFor}. The previous preview is still showing.`;
31695
31784
  logReload("shadow-failed", { cause, waitingFor });
31696
- console.error(`[studio] ${message}`);
31785
+ const refused = refusedPreviewStatus(cause);
31786
+ const pageMissingNow = refused !== null && refused < 500;
31787
+ (pageMissingNow ? console.warn : console.error)(`[studio] ${message}`);
31697
31788
  onReloadFailedRef.current?.(message);
31698
31789
  },
31699
31790
  [stopPendingShadow, isRefreshingRef, pendingSeekRef]
@@ -32162,7 +32253,7 @@ async function probeOne(url) {
32162
32253
  const mb = await loadMediabunny();
32163
32254
  if (!mb) return null;
32164
32255
  const input = new mb.Input({
32165
- source: new mb.UrlSource(url),
32256
+ source: new mb.UrlSource(url, mediaUrlSourceOptions("probe")),
32166
32257
  formats: mb.ALL_FORMATS
32167
32258
  });
32168
32259
  try {
@@ -32178,7 +32269,8 @@ async function probeOne(url) {
32178
32269
  hasAudio: audioTracks.length > 0
32179
32270
  };
32180
32271
  return result;
32181
- } catch {
32272
+ } catch (error) {
32273
+ reportMediaFetchFailure(error);
32182
32274
  return null;
32183
32275
  } finally {
32184
32276
  input.dispose();
@@ -50695,7 +50787,7 @@ function getAnimationEditingBlock(isCurrentSelection, diagnostics) {
50695
50787
  }
50696
50788
  return null;
50697
50789
  }
50698
- function describe(selection, deps, isCurrentSelection, resolvedHandle) {
50790
+ function describe2(selection, deps, isCurrentSelection, resolvedHandle) {
50699
50791
  const { capabilities } = selection;
50700
50792
  const gsap3 = deps.getGsapDiagnostics();
50701
50793
  const animations = isCurrentSelection ? gsap3.animations.map(describeAnimation) : [];
@@ -50746,7 +50838,7 @@ async function studioInspect(deps, input = {}) {
50746
50838
  "Pass a handle from studio_look, or call studio_select first."
50747
50839
  );
50748
50840
  }
50749
- return describe(current, deps, true);
50841
+ return describe2(current, deps, true);
50750
50842
  }
50751
50843
  if (!elementHandleMatchesProject(input.handle, deps.getProjectId())) {
50752
50844
  return toolFailure(
@@ -50780,7 +50872,7 @@ async function studioInspect(deps, input = {}) {
50780
50872
  "Call studio_look again."
50781
50873
  );
50782
50874
  }
50783
- return describe(
50875
+ return describe2(
50784
50876
  resolved2.selection,
50785
50877
  deps,
50786
50878
  current?.element === resolved2.selection.element,
@@ -91090,8 +91182,9 @@ function applyRuntimePreview(runtime, time, properties) {
91090
91182
  usePlayerStore.getState().setCurrentTime(seekTime);
91091
91183
  }
91092
91184
  function recordSample(r, time, properties) {
91093
- const frame3 = secondsToFrame(time);
91094
- const sample = { time: frameToSeconds(frame3), properties: { ...properties } };
91185
+ const fps = useLinkedClipPreferences.getState().compositionFps;
91186
+ const frame3 = secondsToFrame(time, fps);
91187
+ const sample = { time: frameToSeconds(frame3, fps), properties: { ...properties } };
91095
91188
  const lastIndex = r.samples.length - 1;
91096
91189
  const lastSample = r.samples[lastIndex];
91097
91190
  if (lastSample?.time === sample.time) {
package/dist/player.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Player
3
- } from "./chunk-DAZTBGYM.js";
3
+ } from "./chunk-HPIJDMWG.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.206",
3
+ "version": "0.8.208",
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.206",
64
- "@hyperframes/player": "0.8.206",
65
- "@hyperframes/sdk": "0.8.206",
66
- "@hyperframes/shader-transitions": "0.8.206",
67
- "@hyperframes/studio-server": "0.8.206",
68
- "@hyperframes/parsers": "0.8.206"
63
+ "@hyperframes/core": "0.8.208",
64
+ "@hyperframes/parsers": "0.8.208",
65
+ "@hyperframes/sdk": "0.8.208",
66
+ "@hyperframes/shader-transitions": "0.8.208",
67
+ "@hyperframes/player": "0.8.208",
68
+ "@hyperframes/studio-server": "0.8.208"
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.206"
85
+ "@hyperframes/producer": "0.8.208"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -10,6 +10,7 @@ import {
10
10
  patchIframeDomTiming,
11
11
  persistElementAttribute,
12
12
  persistTimelineBatchEdit,
13
+ persistTimelineEdit,
13
14
  type PersistTimelineBatchChange,
14
15
  } from "./timelineEditingHelpers";
15
16
  import type { TimelineElement } from "../player/store/playerStore";
@@ -415,6 +416,64 @@ describe("persistTimelineBatchEdit", () => {
415
416
  });
416
417
  });
417
418
 
419
+ describe("persistTimelineEdit", () => {
420
+ const SOURCE = `<div id="root"><video id="a" class="clip" data-start="1" data-duration="3"></video></div>`;
421
+
422
+ async function runEdit(id: string, start: number) {
423
+ vi.stubGlobal(
424
+ "fetch",
425
+ vi.fn(async () => ({ ok: true, json: async () => ({ content: SOURCE }) })),
426
+ );
427
+ const writes: Array<[string, string]> = [];
428
+ const pending = new Set<string>();
429
+ const element = el({ id, tag: "video", domId: id, start: 1, duration: 3 });
430
+ const done = persistTimelineEdit({
431
+ projectId: "p1",
432
+ element,
433
+ activeCompPath: "index.html",
434
+ label: "Resize timeline clip",
435
+ buildPatches: (original, target) =>
436
+ buildTimelineResizeTimingPatch(original, target, element, {
437
+ start,
438
+ duration: 3,
439
+ playbackStart: undefined,
440
+ }),
441
+ writeProjectFile: async (path, content) => {
442
+ writes.push([path, content]);
443
+ },
444
+ recordEdit: async () => {},
445
+ pendingTimelineEditPathRef: { current: pending },
446
+ });
447
+ return { done, writes, pending };
448
+ }
449
+
450
+ afterEach(() => {
451
+ vi.unstubAllGlobals();
452
+ });
453
+
454
+ it("saves nothing and says nothing when the clip already holds the values (a resize that lands where it began)", async () => {
455
+ // 1.0000001 is a different number from the clip's 1, so the gesture sees a change; the file writes "1" either way.
456
+ const { done, writes, pending } = await runEdit("a", 1.0000001);
457
+ await expect(done).resolves.toBeUndefined();
458
+ expect(writes).toHaveLength(0);
459
+ expect(pending.size).toBe(0);
460
+ });
461
+
462
+ it("writes a real change and marks its file", async () => {
463
+ const { done, writes, pending } = await runEdit("a", 2);
464
+ await done;
465
+ expect(writes).toHaveLength(1);
466
+ expect(writes[0]![1]).toContain('data-start="2"');
467
+ expect([...pending]).toEqual(["index.html"]);
468
+ });
469
+
470
+ it("still throws for a clip the file does not hold", async () => {
471
+ const { done, writes } = await runEdit("ghost", 2);
472
+ await expect(done).rejects.toThrow("Unable to patch timeline element ghost in index.html");
473
+ expect(writes).toHaveLength(0);
474
+ });
475
+ });
476
+
418
477
  describe("deleteSelectedKeyframes", () => {
419
478
  it("coalesces all removals and reloads only after the last one", () => {
420
479
  usePlayerStore.setState({
@@ -351,7 +351,6 @@ export async function persistTimelineEdit(input: PersistTimelineEditInput): Prom
351
351
  throw new Error(`Timeline element ${input.element.id} is missing a patchable target`);
352
352
  }
353
353
 
354
- input.pendingTimelineEditPathRef.current.add(targetPath);
355
354
  await saveProjectFilesWithHistory({
356
355
  projectId: input.projectId,
357
356
  label: input.label,
@@ -359,10 +358,10 @@ export async function persistTimelineEdit(input: PersistTimelineEditInput): Prom
359
358
  coalesceMs: input.coalesceMs,
360
359
  files: {
361
360
  [targetPath]: (current) => {
362
- const patched = input.buildPatches(current, patchTarget);
363
- if (patched === current) {
364
- throw new Error(`Unable to patch timeline element ${input.element.id} in ${targetPath}`);
365
- }
361
+ const patched = patchTimelineChangesInSource(current, targetPath, [
362
+ { element: input.element, buildPatches: input.buildPatches },
363
+ ]);
364
+ if (patched !== current) input.pendingTimelineEditPathRef.current.add(targetPath);
366
365
  return patched;
367
366
  },
368
367
  },
@@ -2,6 +2,7 @@ import { revealClip } from "@hyperframes/core/runtime/clip-reveal";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { usePlayerStore, liveTime } from "../player/store/playerStore";
4
4
  import { frameToSeconds, secondsToFrame } from "../player/lib/time";
5
+ import { useLinkedClipPreferences } from "../utils/linkedClipPreferences";
5
6
 
6
7
  export interface GestureSample {
7
8
  time: number;
@@ -141,12 +142,13 @@ function recordSample(r: RecordingRefs, time: number, properties: Record<string,
141
142
  // stripStudioEditsFromTarget in studio-api), so the keyframes must already
142
143
  // include it. Subtracting it made the committed gesture play shoved off by the
143
144
  // offset (the offset was removed twice).
144
- const frame = secondsToFrame(time);
145
- const sample = { time: frameToSeconds(frame), properties: { ...properties } };
145
+ const fps = useLinkedClipPreferences.getState().compositionFps;
146
+ const frame = secondsToFrame(time, fps);
147
+ const sample = { time: frameToSeconds(frame, fps), properties: { ...properties } };
146
148
  const lastIndex = r.samples.length - 1;
147
149
  const lastSample = r.samples[lastIndex];
148
150
  // Gesture events follow the display refresh rate (often 60/120Hz), but the
149
- // Studio preview is authored at 30fps. Keep the latest pointer state for each
151
+ // composition has its own frame rate. Keep the latest pointer state for each
150
152
  // output frame so recording cannot create visually indistinguishable piles.
151
153
  if (lastSample?.time === sample.time) {
152
154
  r.samples[lastIndex] = sample;