Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
refactor(studio): split oversized files and raise line limit to 600
Miguel Ángelea4d9205899c
diff --git a/.filesize-allowlist b/.filesize-allowlistdeleted file mode 100644index d2dff0d55a..0000000000--- a/.filesize-allowlist+++ /dev/null@@ -1,13 +0,0 @@-packages/studio/src/player/hooks/useTimelinePlayer.ts-packages/studio/src/hooks/useManifestPersistence.ts-packages/studio/src/player/components/PlayerControls.tsx-packages/studio/src/components/editor/manualEdits.test.ts-packages/studio/src/player/hooks/useTimelinePlayer.test.ts-packages/studio/src/components/editor/manualEditsDom.ts-packages/studio/src/utils/sourcePatcher.ts-packages/studio/src/utils/sourcePatcher.test.ts-packages/studio/src/App.tsx-packages/studio/src/player/components/Timeline.tsx-packages/studio/src/player/components/timelineEditing.test.ts-packages/studio/src/components/editor/domEditing.test.ts-packages/studio/src/components/editor/domEditingLayers.tsdiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9852cb65db..805228230e 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -469,7 +469,7 @@ jobs:- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4with:fetch-depth: 0- - name: Check file sizes (max 500 lines)+ - name: Check file sizes (max 600 lines)# Scoped to files THIS PR changed under packages/studio. Walking the# whole tree blamed every unrelated PR for pre-existing offenders.# Falls back to a full scan on push events (no base ref available)@@ -494,10 +494,9 @@ jobs:for f in "${files[@]}"; do[ -z "$f" ] && continue[ -f "$f" ] || continue # skip files deleted in this PR- if grep -qxF "$f" .filesize-allowlist 2>/dev/null; then continue; filines=$(wc -l < "$f")- if [ "$lines" -gt 500 ]; then- echo "::error file=$f::$f has $lines lines (max 500)"+ if [ "$lines" -gt 600 ]; then+ echo "::error file=$f::$f has $lines lines (max 600)"EXIT=1fidonediff --git a/lefthook.yml b/lefthook.ymlindex b2ea469926..7964ed6911 100644--- a/lefthook.yml+++ b/lefthook.yml@@ -21,18 +21,16 @@ pre-commit:glob: "packages/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"run: bunx fallow audit --base origin/main --fail-on-issuesfilesize:- # Scoped to packages/studio — the 500 LOC limit is a studio architecture+ # Scoped to packages/studio — the 600 LOC limit is a studio architecture# standard enforced as part of the App.tsx decomposition work. Player and# other packages enforce size discipline via code review and convention.- # Files temporarily over the limit are listed in .filesize-allowlist.glob: "packages/studio/**/*.{ts,tsx}"exclude: "(\\.test\\.(ts|tsx)$|\\.generated\\.)"run: |for f in {staged_files}; do- if grep -qxF "$f" .filesize-allowlist 2>/dev/null; then continue; filines=$(wc -l < "$f")- if [ "$lines" -gt 500 ]; then- echo "ERROR: $f has $lines lines (max 500) — add to .filesize-allowlist if temporarily needed"+ if [ "$lines" -gt 600 ]; then+ echo "ERROR: $f has $lines lines (max 600)"exit 1fidonediff --git a/packages/studio/src/components/editor/manualEditsDom.ts b/packages/studio/src/components/editor/manualEditsDom.tsindex 3c74006928..f5eb262a76 100644--- a/packages/studio/src/components/editor/manualEditsDom.ts+++ b/packages/studio/src/components/editor/manualEditsDom.ts@@ -31,12 +31,6 @@ import {STUDIO_ROTATION_TRANSFORM_ORIGIN,} from "./manualEditsTypes";import { roundRotationAngle } from "./manualEditsParsing";-import {- STUDIO_MOTION_ATTR,- STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR,- STUDIO_MOTION_ORIGINAL_OPACITY_ATTR,- STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR,-} from "./studioMotionTypes";import { applyStudioMotionFromDom } from "./studioMotion";/* ── Gesture tracking ─────────────────────────────────────────────── */@@ -221,24 +215,28 @@ function writeStudioPathOffsetVars(// into element.style.transform (as a matrix) on every seek. When the studio's reapply hook also// writes `translate`, both properties compose additively, doubling the visual offset. This helper// zeroes out only the translate component (m41/m42) so the `translate` prop isn't double-counted.+function isIdentityAfterTranslateStrip(m: DOMMatrix): boolean {+ return m.is2D && m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1;+}+function stripGsapTranslateFromTransform(element: HTMLElement): void {const transform = element.style.getPropertyValue("transform");if (!transform || transform === "none") return;- const win = element.ownerDocument.defaultView as (Window & typeof globalThis) | null;- const DOMMatrixCtor = (win as unknown as { DOMMatrix?: typeof DOMMatrix })?.DOMMatrix;+ const DOMMatrixCtor = (element.ownerDocument.defaultView as (Window & typeof globalThis) | null)+ ?.DOMMatrix;if (!DOMMatrixCtor) return;try {const m = new DOMMatrixCtor(transform);if (m.m41 === 0 && m.m42 === 0) return;m.m41 = 0;m.m42 = 0;- if (m.is2D && m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1) {+ if (isIdentityAfterTranslateStrip(m)) {element.style.removeProperty("transform");} else {element.style.setProperty("transform", m.toString());}} catch {- // non-parseable transform or DOMMatrix unavailable — leave as-is+ /* non-parseable transform — leave as-is */}}@@ -464,351 +462,30 @@ export function applyStudioRotationDraft(element: HTMLElement, rotation: { angle);}-/* ── HTML patch builders ──────────────────────────────────────────── */-import type { PatchOperation } from "../../utils/sourcePatcher";--export function buildPathOffsetPatches(element: HTMLElement): PatchOperation[] {- const x = element.style.getPropertyValue(STUDIO_OFFSET_X_PROP);- const y = element.style.getPropertyValue(STUDIO_OFFSET_Y_PROP);- const translate = element.style.getPropertyValue("translate");- const originalTranslate = element.getAttribute(STUDIO_ORIGINAL_TRANSLATE_ATTR);- const originalInlineTranslate = element.getAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR);- const displayVal = element.style.getPropertyValue("display");- const transformDisplayAttr = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);- const ops: PatchOperation[] = [];- if (x) ops.push({ type: "inline-style", property: STUDIO_OFFSET_X_PROP, value: x });- if (y) ops.push({ type: "inline-style", property: STUDIO_OFFSET_Y_PROP, value: y });- if (translate) ops.push({ type: "inline-style", property: "translate", value: translate });- ops.push({ type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: "true" });- if (originalTranslate !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_TRANSLATE_ATTR,- value: originalTranslate,- });- if (originalInlineTranslate !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR,- value: originalInlineTranslate,- });- if (displayVal) ops.push({ type: "inline-style", property: "display", value: displayVal });- if (transformDisplayAttr !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR,- value: transformDisplayAttr,- });- return ops;-}--export function buildClearPathOffsetPatches(element: HTMLElement): PatchOperation[] {- const originalInlineTranslate = element.getAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR);- const ops: PatchOperation[] = [- { type: "inline-style", property: STUDIO_OFFSET_X_PROP, value: null },- { type: "inline-style", property: STUDIO_OFFSET_Y_PROP, value: null },- {- type: "inline-style",- property: "translate",- value: originalInlineTranslate || null,- },- { type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: null },- { type: "attribute", property: STUDIO_ORIGINAL_TRANSLATE_ATTR, value: null },- { type: "attribute", property: STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR, value: null },- ];- const origDisplay = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);- if (origDisplay !== null) {- ops.push({ type: "inline-style", property: "display", value: origDisplay || null });- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR, value: null });- }- return ops;-}--export function buildBoxSizePatches(element: HTMLElement): PatchOperation[] {- const ops: PatchOperation[] = [];-- const studioWidth = element.style.getPropertyValue(STUDIO_WIDTH_PROP);- const studioHeight = element.style.getPropertyValue(STUDIO_HEIGHT_PROP);- if (studioWidth)- ops.push({ type: "inline-style", property: STUDIO_WIDTH_PROP, value: studioWidth });- if (studioHeight)- ops.push({ type: "inline-style", property: STUDIO_HEIGHT_PROP, value: studioHeight });-- const width = element.style.getPropertyValue("width");- const height = element.style.getPropertyValue("height");- const minWidth = element.style.getPropertyValue("min-width");- const minHeight = element.style.getPropertyValue("min-height");- const maxWidth = element.style.getPropertyValue("max-width");- const maxHeight = element.style.getPropertyValue("max-height");- const flexBasis = element.style.getPropertyValue("flex-basis");- const flexGrow = element.style.getPropertyValue("flex-grow");- const flexShrink = element.style.getPropertyValue("flex-shrink");- const boxSizing = element.style.getPropertyValue("box-sizing");- const scale = element.style.getPropertyValue("scale");- const transformOrigin = element.style.getPropertyValue("transform-origin");- const displayVal = element.style.getPropertyValue("display");-- if (width) ops.push({ type: "inline-style", property: "width", value: width });- if (height) ops.push({ type: "inline-style", property: "height", value: height });- if (minWidth) ops.push({ type: "inline-style", property: "min-width", value: minWidth });- if (minHeight) ops.push({ type: "inline-style", property: "min-height", value: minHeight });- if (maxWidth) ops.push({ type: "inline-style", property: "max-width", value: maxWidth });- if (maxHeight) ops.push({ type: "inline-style", property: "max-height", value: maxHeight });- if (flexBasis) ops.push({ type: "inline-style", property: "flex-basis", value: flexBasis });- if (flexGrow) ops.push({ type: "inline-style", property: "flex-grow", value: flexGrow });- if (flexShrink) ops.push({ type: "inline-style", property: "flex-shrink", value: flexShrink });- if (boxSizing) ops.push({ type: "inline-style", property: "box-sizing", value: boxSizing });- if (scale) ops.push({ type: "inline-style", property: "scale", value: scale });- if (transformOrigin)- ops.push({ type: "inline-style", property: "transform-origin", value: transformOrigin });- if (displayVal) ops.push({ type: "inline-style", property: "display", value: displayVal });-- ops.push({ type: "attribute", property: STUDIO_BOX_SIZE_ATTR, value: "true" });-- const origWidth = element.getAttribute(STUDIO_ORIGINAL_WIDTH_ATTR);- const origHeight = element.getAttribute(STUDIO_ORIGINAL_HEIGHT_ATTR);- const origMinWidth = element.getAttribute(STUDIO_ORIGINAL_MIN_WIDTH_ATTR);- const origMinHeight = element.getAttribute(STUDIO_ORIGINAL_MIN_HEIGHT_ATTR);- const origMaxWidth = element.getAttribute(STUDIO_ORIGINAL_MAX_WIDTH_ATTR);- const origMaxHeight = element.getAttribute(STUDIO_ORIGINAL_MAX_HEIGHT_ATTR);- const origFlexBasis = element.getAttribute(STUDIO_ORIGINAL_FLEX_BASIS_ATTR);- const origFlexGrow = element.getAttribute(STUDIO_ORIGINAL_FLEX_GROW_ATTR);- const origFlexShrink = element.getAttribute(STUDIO_ORIGINAL_FLEX_SHRINK_ATTR);- const origBoxSizing = element.getAttribute(STUDIO_ORIGINAL_BOX_SIZING_ATTR);- const origScale = element.getAttribute(STUDIO_ORIGINAL_SCALE_ATTR);- const origTransformOrigin = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR);- const origDisplay = element.getAttribute(STUDIO_ORIGINAL_DISPLAY_ATTR);- const origTransformDisplay = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);-- if (origWidth !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_WIDTH_ATTR, value: origWidth });- if (origHeight !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_HEIGHT_ATTR, value: origHeight });- if (origMinWidth !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_MIN_WIDTH_ATTR, value: origMinWidth });- if (origMinHeight !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_MIN_HEIGHT_ATTR,- value: origMinHeight,- });- if (origMaxWidth !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_MAX_WIDTH_ATTR, value: origMaxWidth });- if (origMaxHeight !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_MAX_HEIGHT_ATTR,- value: origMaxHeight,- });- if (origFlexBasis !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_FLEX_BASIS_ATTR,- value: origFlexBasis,- });- if (origFlexGrow !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_FLEX_GROW_ATTR, value: origFlexGrow });- if (origFlexShrink !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_FLEX_SHRINK_ATTR,- value: origFlexShrink,- });- if (origBoxSizing !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_BOX_SIZING_ATTR,- value: origBoxSizing,- });- if (origScale !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_SCALE_ATTR, value: origScale });- if (origTransformOrigin !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR,- value: origTransformOrigin,- });- if (origDisplay !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_DISPLAY_ATTR, value: origDisplay });- if (origTransformDisplay !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR,- value: origTransformDisplay,- });-- return ops;-}--export function buildClearBoxSizePatches(element: HTMLElement): PatchOperation[] {- const ops: PatchOperation[] = [- { type: "inline-style", property: STUDIO_WIDTH_PROP, value: null },- { type: "inline-style", property: STUDIO_HEIGHT_PROP, value: null },- { type: "attribute", property: STUDIO_BOX_SIZE_ATTR, value: null },- ];-- const origAttrs: Array<[string, string]> = [- [STUDIO_ORIGINAL_WIDTH_ATTR, "width"],- [STUDIO_ORIGINAL_HEIGHT_ATTR, "height"],- [STUDIO_ORIGINAL_MIN_WIDTH_ATTR, "min-width"],- [STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, "min-height"],- [STUDIO_ORIGINAL_MAX_WIDTH_ATTR, "max-width"],- [STUDIO_ORIGINAL_MAX_HEIGHT_ATTR, "max-height"],- [STUDIO_ORIGINAL_FLEX_BASIS_ATTR, "flex-basis"],- [STUDIO_ORIGINAL_FLEX_GROW_ATTR, "flex-grow"],- [STUDIO_ORIGINAL_FLEX_SHRINK_ATTR, "flex-shrink"],- [STUDIO_ORIGINAL_BOX_SIZING_ATTR, "box-sizing"],- [STUDIO_ORIGINAL_SCALE_ATTR, "scale"],- [STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR, "transform-origin"],- [STUDIO_ORIGINAL_DISPLAY_ATTR, "display"],- ];-- for (const [attrName, styleProp] of origAttrs) {- const origVal = element.getAttribute(attrName);- if (origVal !== null) {- ops.push({ type: "inline-style", property: styleProp, value: origVal || null });- }- ops.push({ type: "attribute", property: attrName, value: null });- }-- const origTransformDisplay = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);- if (origTransformDisplay !== null) {- ops.push({ type: "inline-style", property: "display", value: origTransformDisplay || null });- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR, value: null });- }+/* ── HTML patch builders (re-exported from manualEditsDomPatches) ── */+export {+ buildPathOffsetPatches,+ buildClearPathOffsetPatches,+ buildBoxSizePatches,+ buildClearBoxSizePatches,+ buildRotationPatches,+ buildClearRotationPatches,+ buildMotionPatches,+ buildClearMotionPatches,+} from "./manualEditsDomPatches";- return ops;-}--export function buildRotationPatches(element: HTMLElement): PatchOperation[] {- const ops: PatchOperation[] = [];-- const studioRotation = element.style.getPropertyValue(STUDIO_ROTATION_PROP);- const rotate = element.style.getPropertyValue("rotate");- const transformOrigin = element.style.getPropertyValue("transform-origin");- const displayVal = element.style.getPropertyValue("display");-- if (studioRotation)- ops.push({ type: "inline-style", property: STUDIO_ROTATION_PROP, value: studioRotation });- if (rotate) ops.push({ type: "inline-style", property: "rotate", value: rotate });- if (transformOrigin)- ops.push({ type: "inline-style", property: "transform-origin", value: transformOrigin });- if (displayVal) ops.push({ type: "inline-style", property: "display", value: displayVal });-- ops.push({ type: "attribute", property: STUDIO_ROTATION_ATTR, value: "true" });+/* ── Seek reapply (position + motion) ────────────────────────────── */- const origRotate = element.getAttribute(STUDIO_ORIGINAL_ROTATE_ATTR);- const origInlineRotate = element.getAttribute(STUDIO_ORIGINAL_INLINE_ROTATE_ATTR);- const origRotationTransformOrigin = element.getAttribute(- STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,+function queryStudioElements(doc: Document, attr: string): HTMLElement[] {+ const ctor = doc.defaultView?.HTMLElement;+ if (!ctor) return [];+ return Array.from(doc.querySelectorAll(`[${attr}="true"]`)).filter(+ (el): el is HTMLElement => el instanceof ctor,);- const origTransformDisplay = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);-- if (origRotate !== null)- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_ROTATE_ATTR, value: origRotate });- if (origInlineRotate !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_INLINE_ROTATE_ATTR,- value: origInlineRotate,- });- if (origRotationTransformOrigin !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,- value: origRotationTransformOrigin,- });- if (origTransformDisplay !== null)- ops.push({- type: "attribute",- property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR,- value: origTransformDisplay,- });-- return ops;-}--export function buildClearRotationPatches(element: HTMLElement): PatchOperation[] {- const origInlineRotate = element.getAttribute(STUDIO_ORIGINAL_INLINE_ROTATE_ATTR);- const origRotationTransformOrigin = element.getAttribute(- STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,- );- const ops: PatchOperation[] = [- { type: "inline-style", property: STUDIO_ROTATION_PROP, value: null },- { type: "inline-style", property: "rotate", value: origInlineRotate || null },- {- type: "inline-style",- property: "transform-origin",- value: origRotationTransformOrigin !== null ? origRotationTransformOrigin || null : null,- },- { type: "attribute", property: STUDIO_ROTATION_ATTR, value: null },- { type: "attribute", property: STUDIO_ROTATION_DRAFT_ATTR, value: null },- { type: "attribute", property: STUDIO_ORIGINAL_ROTATE_ATTR, value: null },- { type: "attribute", property: STUDIO_ORIGINAL_INLINE_ROTATE_ATTR, value: null },- { type: "attribute", property: STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR, value: null },- ];- const origTransformDisplay = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);- if (origTransformDisplay !== null) {- ops.push({ type: "inline-style", property: "display", value: origTransformDisplay || null });- ops.push({ type: "attribute", property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR, value: null });- }- return ops;-}--/* ── Motion HTML patch builders ──────────────────────────────────── */--export function buildMotionPatches(element: HTMLElement): PatchOperation[] {- const motionJson = element.getAttribute(STUDIO_MOTION_ATTR);- if (!motionJson) return [];- const ops: PatchOperation[] = [- { type: "attribute", property: STUDIO_MOTION_ATTR, value: motionJson },- ];- const origTransform = element.getAttribute(STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR);- if (origTransform !== null) {- ops.push({- type: "attribute",- property: STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR,- value: origTransform,- });- }- const origOpacity = element.getAttribute(STUDIO_MOTION_ORIGINAL_OPACITY_ATTR);- if (origOpacity !== null) {- ops.push({- type: "attribute",- property: STUDIO_MOTION_ORIGINAL_OPACITY_ATTR,- value: origOpacity,- });- }- const origVisibility = element.getAttribute(STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR);- if (origVisibility !== null) {- ops.push({- type: "attribute",- property: STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR,- value: origVisibility,- });- }- return ops;-}--export function buildClearMotionPatches(_element: HTMLElement): PatchOperation[] {- return [- { type: "attribute", property: STUDIO_MOTION_ATTR, value: null },- { type: "attribute", property: STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR, value: null },- { type: "attribute", property: STUDIO_MOTION_ORIGINAL_OPACITY_ATTR, value: null },- { type: "attribute", property: STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR, value: null },- ];}-/* ── Seek reapply (position + motion) ────────────────────────────── */--export function reapplyPositionEditsAfterSeek(doc: Document): void {- const htmlElement = doc.defaultView?.HTMLElement;- if (!htmlElement) return;-- const offsetEls = Array.from(doc.querySelectorAll(`[${STUDIO_PATH_OFFSET_ATTR}="true"]`)).filter(- (el): el is HTMLElement => el instanceof htmlElement,- );- for (const el of offsetEls) {+function reapplyPathOffsets(doc: Document): void {+ for (const el of queryStudioElements(doc, STUDIO_PATH_OFFSET_ATTR)) {const x = el.style.getPropertyValue(STUDIO_OFFSET_X_PROP);const y = el.style.getPropertyValue(STUDIO_OFFSET_Y_PROP);if (x || y) {@@ -818,28 +495,30 @@ export function reapplyPositionEditsAfterSeek(doc: Document): void {});}}+}- const boxSizeEls = Array.from(doc.querySelectorAll(`[${STUDIO_BOX_SIZE_ATTR}="true"]`)).filter(- (el): el is HTMLElement => el instanceof htmlElement,- );- for (const el of boxSizeEls) {+function reapplyBoxSizes(doc: Document): void {+ for (const el of queryStudioElements(doc, STUDIO_BOX_SIZE_ATTR)) {const w = Number.parseFloat(el.style.getPropertyValue(STUDIO_WIDTH_PROP));const h = Number.parseFloat(el.style.getPropertyValue(STUDIO_HEIGHT_PROP));if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {applyStudioBoxSize(el, { width: w, height: h });}}+}- const rotationEls = Array.from(doc.querySelectorAll(`[${STUDIO_ROTATION_ATTR}="true"]`)).filter(- (el): el is HTMLElement => el instanceof htmlElement,- );- for (const el of rotationEls) {+function reapplyRotations(doc: Document): void {+ for (const el of queryStudioElements(doc, STUDIO_ROTATION_ATTR)) {const angle = Number.parseFloat(el.style.getPropertyValue(STUDIO_ROTATION_PROP));if (Number.isFinite(angle)) {applyStudioRotation(el, { angle });}}+}- // Reapply DOM-backed motion timeline after seek+export function reapplyPositionEditsAfterSeek(doc: Document): void {+ reapplyPathOffsets(doc);+ reapplyBoxSizes(doc);+ reapplyRotations(doc);applyStudioMotionFromDom(doc);}diff --git a/packages/studio/src/components/editor/manualEditsDomPatches.ts b/packages/studio/src/components/editor/manualEditsDomPatches.tsnew file mode 100644index 0000000000..5329200383--- /dev/null+++ b/packages/studio/src/components/editor/manualEditsDomPatches.ts@@ -0,0 +1,237 @@+import type { PatchOperation } from "../../utils/sourcePatcher";+import {+ STUDIO_OFFSET_X_PROP,+ STUDIO_OFFSET_Y_PROP,+ STUDIO_WIDTH_PROP,+ STUDIO_HEIGHT_PROP,+ STUDIO_ROTATION_PROP,+ STUDIO_PATH_OFFSET_ATTR,+ STUDIO_BOX_SIZE_ATTR,+ STUDIO_ROTATION_ATTR,+ STUDIO_ROTATION_DRAFT_ATTR,+ STUDIO_ORIGINAL_TRANSLATE_ATTR,+ STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR,+ STUDIO_ORIGINAL_WIDTH_ATTR,+ STUDIO_ORIGINAL_HEIGHT_ATTR,+ STUDIO_ORIGINAL_MIN_WIDTH_ATTR,+ STUDIO_ORIGINAL_MIN_HEIGHT_ATTR,+ STUDIO_ORIGINAL_MAX_WIDTH_ATTR,+ STUDIO_ORIGINAL_MAX_HEIGHT_ATTR,+ STUDIO_ORIGINAL_FLEX_BASIS_ATTR,+ STUDIO_ORIGINAL_FLEX_GROW_ATTR,+ STUDIO_ORIGINAL_FLEX_SHRINK_ATTR,+ STUDIO_ORIGINAL_BOX_SIZING_ATTR,+ STUDIO_ORIGINAL_SCALE_ATTR,+ STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR,+ STUDIO_ORIGINAL_DISPLAY_ATTR,+ STUDIO_ORIGINAL_ROTATE_ATTR,+ STUDIO_ORIGINAL_INLINE_ROTATE_ATTR,+ STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,+ STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR,+} from "./manualEditsTypes";+import {+ STUDIO_MOTION_ATTR,+ STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR,+ STUDIO_MOTION_ORIGINAL_OPACITY_ATTR,+ STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR,+} from "./studioMotionTypes";++/* ── Shared helpers ──────────────────────────────────────────────── */++function collectInlineStyleOps(+ element: HTMLElement,+ properties: readonly string[],+ ops: PatchOperation[],+): void {+ for (const prop of properties) {+ const val = element.style.getPropertyValue(prop);+ if (val) ops.push({ type: "inline-style", property: prop, value: val });+ }+}++function collectAttributeOps(+ element: HTMLElement,+ attrNames: readonly string[],+ ops: PatchOperation[],+): void {+ for (const attr of attrNames) {+ const val = element.getAttribute(attr);+ if (val !== null) ops.push({ type: "attribute", property: attr, value: val });+ }+}++function appendTransformDisplayOps(element: HTMLElement, ops: PatchOperation[]): void {+ const val = element.getAttribute(STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR);+ if (val !== null) {+ ops.push({ type: "inline-style", property: "display", value: val || null });+ ops.push({ type: "attribute", property: STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR, value: null });+ }+}++/* ── Path offset patches ─────────────────────────────────────────── */++export function buildPathOffsetPatches(element: HTMLElement): PatchOperation[] {+ const ops: PatchOperation[] = [];+ collectInlineStyleOps(element, [STUDIO_OFFSET_X_PROP, STUDIO_OFFSET_Y_PROP, "translate"], ops);+ ops.push({ type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: "true" });+ collectAttributeOps(+ element,+ [STUDIO_ORIGINAL_TRANSLATE_ATTR, STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR],+ ops,+ );+ collectInlineStyleOps(element, ["display"], ops);+ collectAttributeOps(element, [STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR], ops);+ return ops;+}++export function buildClearPathOffsetPatches(element: HTMLElement): PatchOperation[] {+ const originalInlineTranslate = element.getAttribute(STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR);+ const ops: PatchOperation[] = [+ { type: "inline-style", property: STUDIO_OFFSET_X_PROP, value: null },+ { type: "inline-style", property: STUDIO_OFFSET_Y_PROP, value: null },+ { type: "inline-style", property: "translate", value: originalInlineTranslate || null },+ { type: "attribute", property: STUDIO_PATH_OFFSET_ATTR, value: null },+ { type: "attribute", property: STUDIO_ORIGINAL_TRANSLATE_ATTR, value: null },+ { type: "attribute", property: STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR, value: null },+ ];+ appendTransformDisplayOps(element, ops);+ return ops;+}++/* ── Box size patches ────────────────────────────────────────────── */++const BOX_SIZE_STYLE_PROPS = [+ "width",+ "height",+ "min-width",+ "min-height",+ "max-width",+ "max-height",+ "flex-basis",+ "flex-grow",+ "flex-shrink",+ "box-sizing",+ "scale",+ "transform-origin",+ "display",+] as const;++const BOX_SIZE_ORIG_ATTRS: ReadonlyArray<[string, string]> = [+ [STUDIO_ORIGINAL_WIDTH_ATTR, "width"],+ [STUDIO_ORIGINAL_HEIGHT_ATTR, "height"],+ [STUDIO_ORIGINAL_MIN_WIDTH_ATTR, "min-width"],+ [STUDIO_ORIGINAL_MIN_HEIGHT_ATTR, "min-height"],+ [STUDIO_ORIGINAL_MAX_WIDTH_ATTR, "max-width"],+ [STUDIO_ORIGINAL_MAX_HEIGHT_ATTR, "max-height"],+ [STUDIO_ORIGINAL_FLEX_BASIS_ATTR, "flex-basis"],+ [STUDIO_ORIGINAL_FLEX_GROW_ATTR, "flex-grow"],+ [STUDIO_ORIGINAL_FLEX_SHRINK_ATTR, "flex-shrink"],+ [STUDIO_ORIGINAL_BOX_SIZING_ATTR, "box-sizing"],+ [STUDIO_ORIGINAL_SCALE_ATTR, "scale"],+ [STUDIO_ORIGINAL_TRANSFORM_ORIGIN_ATTR, "transform-origin"],+ [STUDIO_ORIGINAL_DISPLAY_ATTR, "display"],+ [STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR, ""],+];++export function buildBoxSizePatches(element: HTMLElement): PatchOperation[] {+ const ops: PatchOperation[] = [];+ collectInlineStyleOps(element, [STUDIO_WIDTH_PROP, STUDIO_HEIGHT_PROP], ops);+ collectInlineStyleOps(element, BOX_SIZE_STYLE_PROPS, ops);+ ops.push({ type: "attribute", property: STUDIO_BOX_SIZE_ATTR, value: "true" });+ collectAttributeOps(+ element,+ BOX_SIZE_ORIG_ATTRS.map(([attr]) => attr),+ ops,+ );+ return ops;+}++export function buildClearBoxSizePatches(element: HTMLElement): PatchOperation[] {+ const ops: PatchOperation[] = [+ { type: "inline-style", property: STUDIO_WIDTH_PROP, value: null },+ { type: "inline-style", property: STUDIO_HEIGHT_PROP, value: null },+ { type: "attribute", property: STUDIO_BOX_SIZE_ATTR, value: null },+ ];+ for (const [attrName, styleProp] of BOX_SIZE_ORIG_ATTRS) {+ const origVal = element.getAttribute(attrName);+ if (origVal !== null && styleProp) {+ ops.push({ type: "inline-style", property: styleProp, value: origVal || null });+ }+ ops.push({ type: "attribute", property: attrName, value: null });+ }+ return ops;+}++/* ── Rotation patches ────────────────────────────────────────────── */++const ROTATION_STYLE_PROPS = [+ STUDIO_ROTATION_PROP,+ "rotate",+ "transform-origin",+ "display",+] as const;++const ROTATION_ORIG_ATTRS = [+ STUDIO_ORIGINAL_ROTATE_ATTR,+ STUDIO_ORIGINAL_INLINE_ROTATE_ATTR,+ STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,+ STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR,+] as const;++export function buildRotationPatches(element: HTMLElement): PatchOperation[] {+ const ops: PatchOperation[] = [];+ collectInlineStyleOps(element, ROTATION_STYLE_PROPS, ops);+ ops.push({ type: "attribute", property: STUDIO_ROTATION_ATTR, value: "true" });+ collectAttributeOps(element, ROTATION_ORIG_ATTRS, ops);+ return ops;+}++export function buildClearRotationPatches(element: HTMLElement): PatchOperation[] {+ const origInlineRotate = element.getAttribute(STUDIO_ORIGINAL_INLINE_ROTATE_ATTR);+ const origRotationTransformOrigin = element.getAttribute(+ STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR,+ );+ const ops: PatchOperation[] = [+ { type: "inline-style", property: STUDIO_ROTATION_PROP, value: null },+ { type: "inline-style", property: "rotate", value: origInlineRotate || null },+ {+ type: "inline-style",+ property: "transform-origin",+ value: origRotationTransformOrigin !== null ? origRotationTransformOrigin || null : null,+ },+ { type: "attribute", property: STUDIO_ROTATION_ATTR, value: null },+ { type: "attribute", property: STUDIO_ROTATION_DRAFT_ATTR, value: null },+ { type: "attribute", property: STUDIO_ORIGINAL_ROTATE_ATTR, value: null },+ { type: "attribute", property: STUDIO_ORIGINAL_INLINE_ROTATE_ATTR, value: null },+ { type: "attribute", property: STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR, value: null },+ ];+ appendTransformDisplayOps(element, ops);+ return ops;+}++/* ── Motion patches ──────────────────────────────────────────────── */++const MOTION_ORIG_ATTRS = [+ STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR,+ STUDIO_MOTION_ORIGINAL_OPACITY_ATTR,+ STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR,+] as const;++export function buildMotionPatches(element: HTMLElement): PatchOperation[] {+ const motionJson = element.getAttribute(STUDIO_MOTION_ATTR);+ if (!motionJson) return [];+ const ops: PatchOperation[] = [+ { type: "attribute", property: STUDIO_MOTION_ATTR, value: motionJson },+ ];+ collectAttributeOps(element, MOTION_ORIG_ATTRS, ops);+ return ops;+}++export function buildClearMotionPatches(_element: HTMLElement): PatchOperation[] {+ return [+ { type: "attribute", property: STUDIO_MOTION_ATTR, value: null },+ { type: "attribute", property: STUDIO_MOTION_ORIGINAL_TRANSFORM_ATTR, value: null },+ { type: "attribute", property: STUDIO_MOTION_ORIGINAL_OPACITY_ATTR, value: null },+ { type: "attribute", property: STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR, value: null },+ ];+}diff --git a/packages/studio/src/player/components/PlayerControls.tsx b/packages/studio/src/player/components/PlayerControls.tsxindex 05a5c0ffd5..50628ce7d9 100644--- a/packages/studio/src/player/components/PlayerControls.tsx+++ b/packages/studio/src/player/components/PlayerControls.tsx@@ -1,52 +1,319 @@-import { useRef, useState, useCallback, useEffect, memo } from "react";-import { useMountEffect } from "../../hooks/useMountEffect";-import { formatFrameTime, frameToSeconds, stepFrameTime, formatTime } from "../lib/time";+import { useRef, useCallback, useEffect, memo } from "react";+import { formatFrameTime, formatTime, stepFrameTime } from "../lib/time";import { shouldMutePreviewAudio } from "../lib/timelineIframeHelpers";-import { usePlayerStore, liveTime } from "../store/playerStore";+import { usePlayerStore } from "../store/playerStore";import { trackStudioEvent } from "../../utils/studioTelemetry";import { Tooltip } from "../../components/ui";+import { ShortcutsPanel } from "./ShortcutsPanel";+import { SpeedMenu } from "./SpeedMenu";+import { useSeekBarDrag, resolveSeekPercent } from "./useSeekBarDrag";+import { useState } from "react";-const SPEED_OPTIONS = [0.25, 0.5, 1, 1.5, 2] as const;-const SEEK_EDGE_SNAP_PX = 8;+export { resolveSeekPercent };type TimeDisplayMode = "time" | "frame";-const SHORTCUT_SECTIONS = [- {- title: "Playback",- hints: [- { key: "Space", label: "Play / Pause" },- { key: "J", label: "Play backward" },- { key: "K", label: "Stop" },- { key: "L", label: "Play forward" },- { key: "M", label: "Toggle mute" },- { key: "⇧L", label: "Toggle loop" },- { key: "←/→", label: "Step 1 frame" },- { key: "⇧←/⇧→", label: "Step 10 frames" },- { key: "F", label: "Toggle fullscreen" },- ],- },- {- title: "Work area",- hints: [- { key: "I", label: "Set in-point" },- { key: "⇧I", label: "Clear in-point" },- { key: "O", label: "Set out-point" },- { key: "⇧O", label: "Clear out-point" },- { key: "A", label: "Jump to in-point" },- { key: "E", label: "Jump to out-point" },- ],- },-] as const;-export function resolveSeekPercent(clientX: number, rectLeft: number, rectWidth: number): number {- if (!Number.isFinite(rectWidth) || rectWidth <= 0) return 0;- const rawPercent = (clientX - rectLeft) / rectWidth;- const clamped = Math.max(0, Math.min(1, rawPercent));- const snapThreshold = Math.min(0.5, SEEK_EDGE_SNAP_PX / rectWidth);- if (clamped <= snapThreshold) return 0;- if (clamped >= 1 - snapThreshold) return 1;- return clamped;+/* ── Icon sub-components ─────────────────────────────────────────── */++function PlayIcon() {+ return (+ <svg width="12" height="12" viewBox="0 0 24 24" fill="#FAFAFA" aria-hidden="true">+ <polygon points="6,3 20,12 6,21" />+ </svg>+ );+}++function PauseIcon() {+ return (+ <svg width="12" height="12" viewBox="0 0 24 24" fill="#FAFAFA" aria-hidden="true">+ <rect x="6" y="4" width="4" height="16" rx="1" />+ <rect x="14" y="4" width="4" height="16" rx="1" />+ </svg>+ );+}++/* ── Button sub-components ───────────────────────────────────────── */++const MuteButton = memo(function MuteButton({+ audioMuted,+ audioAutoMuted,+ effectiveAudioMuted,+ controlsDisabled,+ setAudioMuted,+}: {+ audioMuted: boolean;+ audioAutoMuted: boolean;+ effectiveAudioMuted: boolean;+ controlsDisabled: boolean;+ setAudioMuted: (v: boolean) => void;+}) {+ const label = audioAutoMuted+ ? "Audio muted above 1x speed"+ : audioMuted+ ? "Unmute audio"+ : "Mute audio";+ return (+ <Tooltip label={label}>+ <button+ type="button"+ onClick={() => {+ if (!audioAutoMuted) {+ trackStudioEvent("playback", { action: "mute_toggle", muted: !audioMuted });+ setAudioMuted(!audioMuted);+ }+ }}+ disabled={controlsDisabled || audioAutoMuted}+ aria-label={label}+ aria-pressed={effectiveAudioMuted}+ className={`h-7 w-7 flex-shrink-0 flex items-center justify-center rounded-md border transition-colors disabled:pointer-events-none ${+ effectiveAudioMuted+ ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"+ : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"+ } ${audioAutoMuted ? "opacity-70" : ""}`}+ >+ <svg+ width="13"+ height="13"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ <path d="M11 5 6 9H3v6h3l5 4V5Z" />+ {effectiveAudioMuted ? (+ <>+ <path d="m19 9-6 6" />+ <path d="m13 9 6 6" />+ </>+ ) : (+ <>+ <path d="M15.5 8.5a5 5 0 0 1 0 7" />+ <path d="M18.5 5.5a9 9 0 0 1 0 13" />+ </>+ )}+ </svg>+ </button>+ </Tooltip>+ );+});++const LoopButton = memo(function LoopButton({+ loopEnabled,+ disabled,+ setLoopEnabled,+}: {+ loopEnabled: boolean;+ disabled: boolean;+ setLoopEnabled: (v: boolean) => void;+}) {+ return (+ <Tooltip label="Loop playback">+ <button+ type="button"+ onClick={() => {+ trackStudioEvent("playback", { action: "loop_toggle", enabled: !loopEnabled });+ setLoopEnabled(!loopEnabled);+ }}+ disabled={disabled}+ className={`h-7 w-7 flex items-center justify-center rounded-md border transition-colors ${+ loopEnabled+ ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"+ : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"+ }`}+ aria-label={loopEnabled ? "Disable loop playback" : "Enable loop playback"}+ aria-pressed={loopEnabled}+ >+ <svg+ width="13"+ height="13"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ <path d="M17 2l4 4-4 4" />+ <path d="M3 11V9a4 4 0 0 1 4-4h14" />+ <path d="M7 22l-4-4 4-4" />+ <path d="M21 13v2a4 4 0 0 1-4 4H3" />+ </svg>+ </button>+ </Tooltip>+ );+});++const FullscreenButton = memo(function FullscreenButton({+ isFullscreen,+ onToggleFullscreen,+}: {+ isFullscreen: boolean;+ onToggleFullscreen: () => void;+}) {+ return (+ <Tooltip label={isFullscreen ? "Exit fullscreen (F)" : "Enter fullscreen (F)"}>+ <button+ type="button"+ onClick={() => {+ trackStudioEvent("playback", { action: "fullscreen_toggle", active: !isFullscreen });+ onToggleFullscreen();+ }}+ className={`h-7 w-7 flex-shrink-0 flex items-center justify-center rounded-md border transition-colors ${+ isFullscreen+ ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"+ : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"+ }`}+ aria-label={isFullscreen ? "Exit fullscreen" : "Enter fullscreen"}+ >+ <svg+ width="13"+ height="13"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ {isFullscreen ? (+ <>+ <path d="M8 3v3a2 2 0 0 1-2 2H3" />+ <path d="M21 8h-3a2 2 0 0 1-2-2V3" />+ <path d="M3 16h3a2 2 0 0 1 2 2v3" />+ <path d="M16 21v-3a2 2 0 0 1 2-2h3" />+ </>+ ) : (+ <>+ <path d="M8 3H5a2 2 0 0 0-2 2v3" />+ <path d="M21 8V5a2 2 0 0 0-2-2h-3" />+ <path d="M3 16v3a2 2 0 0 0 2 2h3" />+ <path d="M16 21h3a2 2 0 0 0 2-2v-3" />+ </>+ )}+ </svg>+ </button>+ </Tooltip>+ );+});++/* ── Seek bar sub-component ──────────────────────────────────────── */++function SeekBarMarker({ position, duration }: { position: number; duration: number }) {+ if (duration <= 0) return null;+ return (+ <div+ className="absolute z-[3] pointer-events-none"+ style={{+ left: `${Math.min(100, (position / duration) * 100)}%`,+ top: "50%",+ transform: "translate(-50%, -50%)",+ width: "2px",+ height: "10px",+ background: "#3CE6AC",+ borderRadius: "1px",+ }}+ />+ );+}++function WorkAreaOverlay({+ inPoint,+ outPoint,+ duration,+}: {+ inPoint: number | null;+ outPoint: number | null;+ duration: number;+}) {+ if ((inPoint === null && outPoint === null) || duration <= 0) return null;+ return (+ <>+ <div+ className="absolute top-0 bottom-0 pointer-events-none"+ style={{+ left: `${inPoint !== null ? Math.min(100, (inPoint / duration) * 100) : 0}%`,+ right: `${outPoint !== null ? 100 - Math.min(100, (outPoint / duration) * 100) : 0}%`,+ background: "rgba(60,230,172,0.15)",+ }}+ />+ {inPoint !== null && <SeekBarMarker position={inPoint} duration={duration} />}+ {outPoint !== null && <SeekBarMarker position={outPoint} duration={duration} />}+ </>+ );}+const SeekBar = memo(function SeekBar({+ disabled,+ duration,+ inPoint,+ outPoint,+ progressFillRef,+ progressThumbRef,+ seekBarRef,+ sliderRef,+ onPointerDown,+ onKeyDown,+}: {+ disabled: boolean;+ duration: number;+ inPoint: number | null;+ outPoint: number | null;+ progressFillRef: React.RefObject<HTMLDivElement | null>;+ progressThumbRef: React.RefObject<HTMLDivElement | null>;+ seekBarRef: React.RefObject<HTMLDivElement | null>;+ sliderRef: React.RefObject<HTMLDivElement | null>;+ onPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;+ onKeyDown: (e: React.KeyboardEvent) => void;+}) {+ return (+ <div+ ref={(el) => {+ (seekBarRef as React.MutableRefObject<HTMLDivElement | null>).current = el;+ (sliderRef as React.MutableRefObject<HTMLDivElement | null>).current = el;+ }}+ role="slider"+ tabIndex={disabled ? -1 : 0}+ aria-label="Seek"+ aria-disabled={disabled || undefined}+ aria-valuemin={0}+ aria-valuemax={Math.round(duration)}+ aria-valuenow={0}+ className={`min-w-[96px] flex-1 h-6 flex items-center group ${+ disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"+ }`}+ style={{ touchAction: "none" }}+ onPointerDown={onPointerDown}+ onKeyDown={onKeyDown}+ >+ <div+ className="w-full rounded-full relative"+ style={{ background: "rgba(255,255,255,0.15)", height: "3px" }}+ >+ <WorkAreaOverlay inPoint={inPoint} outPoint={outPoint} duration={duration} />+ <div+ ref={progressFillRef}+ className="absolute top-0 bottom-0 left-0 z-[1] rounded-full"+ style={{ background: "linear-gradient(90deg, var(--hf-accent, #3CE6AC), #2BBFA0)" }}+ />+ <div+ ref={progressThumbRef}+ className="absolute top-1/2 z-[4] w-3 h-3 rounded-full -translate-y-1/2 -translate-x-1/2 transition-transform group-hover:scale-125"+ style={{+ background: "var(--hf-accent, #3CE6AC)",+ boxShadow: "0 0 6px rgba(60,230,172,0.4), 0 1px 4px rgba(0,0,0,0.4)",+ }}+ />+ </div>+ </div>+ );+});++/* ── Main component ──────────────────────────────────────────────── */+interface PlayerControlsProps {onTogglePlay: () => void;onSeek: (time: number) => void;@@ -62,7 +329,6 @@ export const PlayerControls = memo(function PlayerControls({isFullscreen = false,onToggleFullscreen,}: PlayerControlsProps) {- // Subscribe to only the fields we render — each selector prevents cascading re-rendersconst isPlaying = usePlayerStore((s) => s.isPlaying);const duration = usePlayerStore((s) => s.duration);const timelineReady = usePlayerStore((s) => s.timelineReady);@@ -76,18 +342,13 @@ export const PlayerControls = memo(function PlayerControls({const outPoint = usePlayerStore((s) => s.outPoint);const setInPoint = usePlayerStore.getState().setInPoint;const setOutPoint = usePlayerStore.getState().setOutPoint;- const [showSpeedMenu, setShowSpeedMenu] = useState(false);- const [showShortcuts, setShowShortcuts] = useState(false);const [timeDisplayMode, setTimeDisplayMode] = useState<TimeDisplayMode>("time");- const [jumpFrame, setJumpFrame] = useState("");const progressFillRef = useRef<HTMLDivElement>(null);const progressThumbRef = useRef<HTMLDivElement>(null);const timeDisplayRef = useRef<HTMLSpanElement>(null);const seekBarRef = useRef<HTMLDivElement>(null);const sliderRef = useRef<HTMLDivElement>(null);- const speedMenuContainerRef = useRef<HTMLDivElement>(null);- const shortcutsPanelRef = useRef<HTMLDivElement>(null);const isDraggingRef = useRef(false);const currentTimeRef = useRef(0);const timeDisplayModeRef = useRef(timeDisplayMode);@@ -98,43 +359,6 @@ export const PlayerControls = memo(function PlayerControls({const controlsDisabled = disabled || !timelineReady;const audioAutoMuted = playbackRate > 1;const effectiveAudioMuted = shouldMutePreviewAudio(audioMuted, playbackRate);- const muteButtonLabel = audioAutoMuted- ? "Audio muted above 1x speed"- : audioMuted- ? "Unmute audio"- : "Mute audio";- useMountEffect(() => {- const updateProgress = (t: number) => {- currentTimeRef.current = t;- const dur = durationRef.current;- const pct = dur > 0 ? Math.min(100, (t / dur) * 100) : 0;- if (progressFillRef.current) progressFillRef.current.style.width = `${pct}%`;- if (progressThumbRef.current) progressThumbRef.current.style.left = `${pct}%`;- if (timeDisplayRef.current) {- timeDisplayRef.current.textContent =- timeDisplayModeRef.current === "frame" ? formatFrameTime(t, dur) : formatTime(t);- }- if (sliderRef.current) sliderRef.current.setAttribute("aria-valuenow", String(Math.round(t)));- };- const unsub = liveTime.subscribe(updateProgress);- updateProgress(usePlayerStore.getState().currentTime);-- // Also poll every 500ms as a fallback in case liveTime doesn't fire- const interval = setInterval(() => {- const t = usePlayerStore.getState().currentTime;- const dur = usePlayerStore.getState().duration;- if (dur > 0 && t > 0) {- const pct = Math.min(100, (t / dur) * 100);- if (progressFillRef.current) progressFillRef.current.style.width = `${pct}%`;- if (progressThumbRef.current) progressThumbRef.current.style.left = `${pct}%`;- }- }, 500);-- return () => {- unsub();- clearInterval(interval);- };- });useEffect(() => {if (!timeDisplayRef.current) return;@@ -143,150 +367,21 @@ export const PlayerControls = memo(function PlayerControls({timeDisplayMode === "frame" ? formatFrameTime(t, duration) : formatTime(t);}, [duration, timeDisplayMode]);- useEffect(() => {- if (!showSpeedMenu) return;- const handleMouseDown = (e: MouseEvent) => {- if (- speedMenuContainerRef.current &&- !speedMenuContainerRef.current.contains(e.target as Node)- ) {- setShowSpeedMenu(false);- }- };- document.addEventListener("mousedown", handleMouseDown);- return () => {- document.removeEventListener("mousedown", handleMouseDown);- };- }, [showSpeedMenu]);-- useEffect(() => {- if (!showShortcuts) return;- const handleMouseDown = (e: MouseEvent) => {- if (shortcutsPanelRef.current && !shortcutsPanelRef.current.contains(e.target as Node)) {- setShowShortcuts(false);- }- };- document.addEventListener("mousedown", handleMouseDown);- return () => {- document.removeEventListener("mousedown", handleMouseDown);- };- }, [showShortcuts]);-- const seekFromClientX = useCallback(- (clientX: number) => {- if (disabled) return;- const bar = seekBarRef.current;- if (!bar || duration <= 0) return;- const rect = bar.getBoundingClientRect();- const percent = resolveSeekPercent(clientX, rect.left, rect.width);- // Immediately update progress bar visuals (don't wait for liveTime round-trip)- const pct = percent * 100;- if (progressFillRef.current) progressFillRef.current.style.width = `${pct}%`;- if (progressThumbRef.current) progressThumbRef.current.style.left = `${pct}%`;- onSeek(percent * duration);- },- [disabled, duration, onSeek],- );-- const handlePointerDown = useCallback(- (e: React.PointerEvent<HTMLDivElement>) => {- // Ignore secondary mouse buttons — only primary (left click / touch /- // pen contact) should start a drag.- if (e.button !== 0) return;- e.preventDefault();- // preventDefault() on pointerdown also suppresses the implicit focus- // transfer that click normally grants a `tabIndex=0` element — which- // matches native `<input type="range">` behavior, but it also means a- // click-then-arrow-key workflow wouldn't work. Restore focus explicitly- // so seeking by click and nudging by arrow keys compose naturally.- e.currentTarget.focus();- isDraggingRef.current = true;-- // `setPointerCapture` routes every subsequent pointermove/up to the- // slider element even when the pointer leaves its bounding box. Without- // it, fast drags on touch would lose events the moment the finger- // slips outside the 6 px-tall hit zone.- const target = e.currentTarget;- const pointerId = e.pointerId;- try {- target.setPointerCapture(pointerId);- } catch {- /* non-supporting browsers fall back to window listeners below */- }-- seekFromClientX(e.clientX);-- // During drag, update the slider visual immediately on every pointer- // event but RAF-throttle the actual onSeek call. The seek path triggers- // adapter.seek + setCurrentTime + React re-renders which can take >16ms- // on complex compositions — keeping visual feedback on the raw event and- // batching the expensive work to one call per frame keeps scrubbing at- // 60 fps.- let seekRafId = 0;- let pendingClientX = e.clientX;- const onMove = (ev: PointerEvent) => {- if (ev.pointerId !== pointerId || !isDraggingRef.current) return;- pendingClientX = ev.clientX;- const bar = seekBarRef.current;- const dur = durationRef.current;- if (bar && dur > 0) {- const rect = bar.getBoundingClientRect();- const pct = resolveSeekPercent(ev.clientX, rect.left, rect.width) * 100;- if (progressFillRef.current) progressFillRef.current.style.width = `${pct}%`;- if (progressThumbRef.current) progressThumbRef.current.style.left = `${pct}%`;- }- if (!seekRafId) {- seekRafId = requestAnimationFrame(() => {- seekRafId = 0;- if (isDraggingRef.current) seekFromClientX(pendingClientX);- });- }- };- const cleanup = () => {- isDraggingRef.current = false;- if (seekRafId) {- cancelAnimationFrame(seekRafId);- seekRafId = 0;- }- seekFromClientX(pendingClientX);- try {- target.releasePointerCapture(pointerId);- } catch {- /* Already released after the first cleanup — second invocation- via the window-fallback or visibility path is a no-op throw. */- }- target.removeEventListener("pointermove", onMove);- target.removeEventListener("pointerup", onUp);- target.removeEventListener("pointercancel", onUp);- window.removeEventListener("pointerup", onUp);- window.removeEventListener("pointercancel", onUp);- document.removeEventListener("visibilitychange", onVisibilityChange);- window.removeEventListener("blur", cleanup);- };- const onUp = (ev: PointerEvent) => {- if (ev.pointerId !== pointerId) return;- cleanup();- };- // iOS Safari does not reliably fire `pointercancel` when the page is- // backgrounded mid-drag (alt-tab, incoming call, switch apps). Without- // a release path the ref stays `true` until the next pointerdown — a- // stuck-scrubber class bug waiting to happen if anyone later gates- // rendering on `isDragging`. Synthesize the release on hide / blur.- const onVisibilityChange = () => {- if (document.visibilityState === "hidden") cleanup();- };-- target.addEventListener("pointermove", onMove);- target.addEventListener("pointerup", onUp);- target.addEventListener("pointercancel", onUp);- // Window-level fallback in case capture fails and the pointer release- // lands outside the element (rare, but defensive).- window.addEventListener("pointerup", onUp);- window.addEventListener("pointercancel", onUp);- document.addEventListener("visibilitychange", onVisibilityChange);- window.addEventListener("blur", cleanup);+ const { handlePointerDown } = useSeekBarDrag(+ {+ seekBarRef,+ progressFillRef,+ progressThumbRef,+ sliderRef,+ timeDisplayRef,+ isDraggingRef,+ durationRef,+ currentTimeRef,+ timeDisplayModeRef,},- [seekFromClientX],+ onSeek,+ disabled,+ duration,);const handleKeyDown = useCallback(@@ -304,43 +399,15 @@ export const PlayerControls = memo(function PlayerControls({[disabled, timelineReady, duration, onSeek],);- const commitJumpFrame = useCallback(() => {- if (disabled) return;- const frame = Number.parseInt(jumpFrame, 10);- if (!Number.isFinite(frame) || duration <= 0) return;- onSeek(Math.min(duration, frameToSeconds(Math.max(0, frame))));- }, [disabled, duration, jumpFrame, onSeek]);-- const handleJumpSubmit = useCallback(- (e: React.FormEvent) => {- e.preventDefault();- commitJumpFrame();- },- [commitJumpFrame],- );-- const handleJumpKeyDown = useCallback(- (e: React.KeyboardEvent<HTMLInputElement>) => {- if (e.key !== "Enter") return;- e.preventDefault();- commitJumpFrame();- },- [commitJumpFrame],- );-return (<divclassName="px-4 py-2 flex flex-wrap items-center gap-x-2 gap-y-1"aria-disabled={disabled || undefined}style={{borderTop: "1px solid rgba(255,255,255,0.04)",- // Add iOS safe-area inset so Safari's bottom URL bar doesn't occlude- // the Play button + timecode on iPhone. `env(safe-area-inset-bottom)`- // is 0 everywhere else, so this is a no-op on desktop.paddingBottom: "calc(0.5rem + env(safe-area-inset-bottom))",}}>- {/* Play/Pause button */}<Tooltip label={isPlaying ? "Pause" : "Play"}><buttontype="button"@@ -353,20 +420,10 @@ export const PlayerControls = memo(function PlayerControls({className="flex-shrink-0 w-8 h-8 flex items-center justify-center rounded-lg disabled:opacity-30 disabled:pointer-events-none transition-colors"style={{ background: "rgba(255,255,255,0.06)" }}>- {isPlaying ? (- <svg width="12" height="12" viewBox="0 0 24 24" fill="#FAFAFA" aria-hidden="true">- <rect x="6" y="4" width="4" height="16" rx="1" />- <rect x="14" y="4" width="4" height="16" rx="1" />- </svg>- ) : (- <svg width="12" height="12" viewBox="0 0 24 24" fill="#FAFAFA" aria-hidden="true">- <polygon points="6,3 20,12 6,21" />- </svg>- )}+ {isPlaying ? <PauseIcon /> : <PlayIcon />}</button></Tooltip>- {/* Time display — click to toggle time/frame mode */}<Tooltiplabel={timeDisplayMode === "time" ? "Switch to frame display" : "Switch to time display"}>@@ -387,470 +444,48 @@ export const PlayerControls = memo(function PlayerControls({</button></Tooltip>- {/* Seek bar — teal progress fill */}- <div- ref={(el) => {- (seekBarRef as React.MutableRefObject<HTMLDivElement | null>).current = el;- (sliderRef as React.MutableRefObject<HTMLDivElement | null>).current = el;- }}- role="slider"- tabIndex={disabled ? -1 : 0}- aria-label="Seek"- aria-disabled={disabled || undefined}- aria-valuemin={0}- aria-valuemax={Math.round(duration)}- aria-valuenow={0}- className={`min-w-[96px] flex-1 h-6 flex items-center group ${- disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"- }`}- // `touch-action: none` tells the browser we're handling every- // pointer gesture on this element ourselves. Without it, iOS- // Safari consumes horizontal swipes for its own swipe-back-to-- // previous-page navigation and the scrubber can't drag left.- style={{ touchAction: "none" }}+ <SeekBar+ disabled={disabled}+ duration={duration}+ inPoint={inPoint}+ outPoint={outPoint}+ progressFillRef={progressFillRef}+ progressThumbRef={progressThumbRef}+ seekBarRef={seekBarRef}+ sliderRef={sliderRef}onPointerDown={handlePointerDown}onKeyDown={handleKeyDown}- >- <div- className="w-full rounded-full relative"- style={{ background: "rgba(255,255,255,0.15)", height: "3px" }}- >- {/* Work-area band between in/out points */}- {(inPoint !== null || outPoint !== null) && duration > 0 && (- <div- className="absolute top-0 bottom-0 pointer-events-none"- style={{- left: `${inPoint !== null ? Math.min(100, (inPoint / duration) * 100) : 0}%`,- right: `${outPoint !== null ? 100 - Math.min(100, (outPoint / duration) * 100) : 0}%`,- background: "rgba(60,230,172,0.15)",- }}- />- )}- {/* Progress fill — width is controlled imperatively via ref to avoid React re-render resets */}- <div- ref={progressFillRef}- className="absolute top-0 bottom-0 left-0 z-[1] rounded-full"- style={{ background: "linear-gradient(90deg, var(--hf-accent, #3CE6AC), #2BBFA0)" }}- />- {/* In-point marker */}- {inPoint !== null && duration > 0 && (- <div- className="absolute z-[3] pointer-events-none"- style={{- left: `${Math.min(100, (inPoint / duration) * 100)}%`,- top: "50%",- transform: "translate(-50%, -50%)",- width: "2px",- height: "10px",- background: "#3CE6AC",- borderRadius: "1px",- }}- />- )}- {/* Out-point marker */}- {outPoint !== null && duration > 0 && (- <div- className="absolute z-[3] pointer-events-none"- style={{- left: `${Math.min(100, (outPoint / duration) * 100)}%`,- top: "50%",- transform: "translate(-50%, -50%)",- width: "2px",- height: "10px",- background: "#3CE6AC",- borderRadius: "1px",- }}- />- )}- {/* Playhead thumb — left is controlled imperatively via ref */}- <div- ref={progressThumbRef}- className="absolute top-1/2 z-[4] w-3 h-3 rounded-full -translate-y-1/2 -translate-x-1/2 transition-transform group-hover:scale-125"- style={{- background: "var(--hf-accent, #3CE6AC)",- boxShadow: "0 0 6px rgba(60,230,172,0.4), 0 1px 4px rgba(0,0,0,0.4)",- }}- />- </div>- </div>+ />- {/* Mute toggle */}- <Tooltip label={muteButtonLabel}>- <button- type="button"- onClick={() => {- if (!audioAutoMuted) {- trackStudioEvent("playback", { action: "mute_toggle", muted: !audioMuted });- setAudioMuted(!audioMuted);- }- }}- disabled={controlsDisabled || audioAutoMuted}- aria-label={muteButtonLabel}- aria-pressed={effectiveAudioMuted}- className={`h-7 w-7 flex-shrink-0 flex items-center justify-center rounded-md border transition-colors disabled:pointer-events-none ${- effectiveAudioMuted- ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"- : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"- } ${audioAutoMuted ? "opacity-70" : ""}`}- >- {effectiveAudioMuted ? (- <svg- width="13"- height="13"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <path d="M11 5 6 9H3v6h3l5 4V5Z" />- <path d="m19 9-6 6" />- <path d="m13 9 6 6" />- </svg>- ) : (- <svg- width="13"- height="13"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <path d="M11 5 6 9H3v6h3l5 4V5Z" />- <path d="M15.5 8.5a5 5 0 0 1 0 7" />- <path d="M18.5 5.5a9 9 0 0 1 0 13" />- </svg>- )}- </button>- </Tooltip>+ <MuteButton+ audioMuted={audioMuted}+ audioAutoMuted={audioAutoMuted}+ effectiveAudioMuted={effectiveAudioMuted}+ controlsDisabled={controlsDisabled}+ setAudioMuted={setAudioMuted}+ />- {/* Speed control */}- <div ref={speedMenuContainerRef} className="relative flex-shrink-0">- <Tooltip label="Playback speed">- <button- type="button"- onClick={() => setShowSpeedMenu((v) => !v)}- disabled={disabled}- className="w-10 px-2 py-1 rounded-md text-[10px] font-mono tabular-nums transition-colors"- style={{ color: "#71717A", background: "rgba(255,255,255,0.04)" }}- >- {playbackRate === 1 ? "1x" : `${playbackRate}x`}- </button>- </Tooltip>- {showSpeedMenu && (- <div- className="absolute bottom-full right-0 mb-1.5 rounded-lg shadow-xl z-50 min-w-[56px] overflow-hidden"- style={{ background: "#161618", border: "1px solid rgba(255,255,255,0.08)" }}- >- {SPEED_OPTIONS.map((rate) => (- <button- key={rate}- onClick={() => {- trackStudioEvent("playback", { action: "speed_change", rate });- setPlaybackRate(rate);- setShowSpeedMenu(false);- }}- className="block w-full px-3 py-1.5 text-[11px] text-left font-mono tabular-nums transition-colors"- style={{- color: rate === playbackRate ? "#FAFAFA" : "#71717A",- background: rate === playbackRate ? "rgba(255,255,255,0.06)" : "transparent",- }}- onMouseEnter={(e) => {- if (rate !== playbackRate)- e.currentTarget.style.background = "rgba(255,255,255,0.04)";- }}- onMouseLeave={(e) => {- if (rate !== playbackRate) e.currentTarget.style.background = "transparent";- }}- >- {rate}x- </button>- ))}- </div>- )}- </div>+ <SpeedMenu+ playbackRate={playbackRate}+ setPlaybackRate={setPlaybackRate}+ disabled={disabled}+ />- <Tooltip label="Loop playback">- <button- type="button"- onClick={() => {- trackStudioEvent("playback", { action: "loop_toggle", enabled: !loopEnabled });- setLoopEnabled(!loopEnabled);- }}- disabled={disabled}- className={`h-7 w-7 flex items-center justify-center rounded-md border transition-colors ${- loopEnabled- ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"- : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"- }`}- aria-label={loopEnabled ? "Disable loop playback" : "Enable loop playback"}- aria-pressed={loopEnabled}- >- <svg- width="13"- height="13"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <path d="M17 2l4 4-4 4" />- <path d="M3 11V9a4 4 0 0 1 4-4h14" />- <path d="M7 22l-4-4 4-4" />- <path d="M21 13v2a4 4 0 0 1-4 4H3" />- </svg>- </button>- </Tooltip>+ <LoopButton loopEnabled={loopEnabled} disabled={disabled} setLoopEnabled={setLoopEnabled} />- {/* Fullscreen toggle */}{onToggleFullscreen && (- <Tooltip label={isFullscreen ? "Exit fullscreen (F)" : "Enter fullscreen (F)"}>- <button- type="button"- onClick={() => {- trackStudioEvent("playback", { action: "fullscreen_toggle", active: !isFullscreen });- onToggleFullscreen();- }}- className={`h-7 w-7 flex-shrink-0 flex items-center justify-center rounded-md border transition-colors ${- isFullscreen- ? "text-studio-accent bg-studio-accent/10 border-studio-accent/30"- : "border-neutral-700 text-neutral-400 hover:border-neutral-500 hover:bg-neutral-800"- }`}- aria-label={isFullscreen ? "Exit fullscreen" : "Enter fullscreen"}- >- {isFullscreen ? (- <svg- width="13"- height="13"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <path d="M8 3v3a2 2 0 0 1-2 2H3" />- <path d="M21 8h-3a2 2 0 0 1-2-2V3" />- <path d="M3 16h3a2 2 0 0 1 2 2v3" />- <path d="M16 21v-3a2 2 0 0 1 2-2h3" />- </svg>- ) : (- <svg- width="13"- height="13"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <path d="M8 3H5a2 2 0 0 0-2 2v3" />- <path d="M21 8V5a2 2 0 0 0-2-2h-3" />- <path d="M3 16v3a2 2 0 0 0 2 2h3" />- <path d="M16 21h3a2 2 0 0 0 2-2v-3" />- </svg>- )}- </button>- </Tooltip>+ <FullscreenButton isFullscreen={isFullscreen} onToggleFullscreen={onToggleFullscreen} />)}- {/* Keyboard shortcuts + frame jump + work area — click to open panel */}- <div ref={shortcutsPanelRef} className="relative flex-shrink-0">- <Tooltip label="Shortcuts and tools">- <button- type="button"- onClick={() => setShowShortcuts((v) => !v)}- className={`w-6 h-6 flex items-center justify-center rounded border transition-colors ${- showShortcuts- ? "border-neutral-600 text-neutral-200 bg-neutral-800"- : "border-neutral-800 text-neutral-600 hover:text-neutral-300 hover:border-neutral-600"- }`}- aria-label="Shortcuts and tools"- aria-expanded={showShortcuts}- >- <svg- width="11"- height="11"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.75"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- >- <rect x="2" y="4" width="20" height="16" rx="2" />- <path d="M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M10 12h.01M14 12h.01M18 12h.01M8 16h8" />- </svg>- </button>- </Tooltip>- {showShortcuts && (- <div- className="absolute bottom-full right-0 mb-2 z-50 rounded-lg shadow-xl min-w-[220px] overflow-y-auto"- style={{- background: "#161618",- border: "1px solid rgba(255,255,255,0.08)",- maxHeight: "min(280px, calc(100vh - 80px))",- }}- >- {/* Frame jump */}- <div className="px-3 pt-3 pb-2.5">- <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">- Jump to frame- </p>- <form onSubmit={handleJumpSubmit} className="flex items-center gap-1.5">- <input- value={jumpFrame}- onChange={(e) => setJumpFrame(e.target.value)}- disabled={disabled}- inputMode="numeric"- pattern="[0-9]*"- aria-label="Jump to frame"- placeholder="frame number"- className="h-6 flex-1 rounded border border-neutral-700 bg-neutral-900 px-2 text-[10px] font-mono tabular-nums text-neutral-200 outline-none transition-colors placeholder:text-neutral-600 focus:border-studio-accent/60"- onKeyDown={handleJumpKeyDown}- onBlur={commitJumpFrame}- />- <Tooltip label="Jump to frame">- <button- type="submit"- disabled={disabled}- className="h-6 px-2 rounded border border-neutral-700 text-[10px] text-neutral-300 transition-colors hover:border-neutral-500 hover:bg-neutral-800 disabled:opacity-40"- >- Go- </button>- </Tooltip>- </form>- </div>- <div style={{ borderTop: "1px solid rgba(255,255,255,0.06)" }} />- {/* Work area */}- <div className="px-3 pt-2.5 pb-2">- <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">- Work area- </p>- <div className="flex flex-col gap-1">- <div className="flex items-center justify-between gap-2">- <div className="flex items-center gap-2">- <span- className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[20px] text-center"- style={{ background: "rgba(255,255,255,0.05)" }}- >- I- </span>- <span className="text-[10px] text-neutral-400">In-point</span>- </div>- <div className="flex items-center gap-1.5">- {inPoint !== null ? (- <>- <span className="font-mono text-[10px] text-neutral-300">- {formatTime(inPoint)}- </span>- <Tooltip label="Clear in-point">- <button- type="button"- onClick={() => setInPoint(null)}- className="w-4 h-4 flex items-center justify-center rounded text-neutral-500 hover:text-neutral-200 transition-colors"- aria-label="Clear in-point"- >- <svg- width="8"- height="8"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2.5"- >- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- </Tooltip>- </>- ) : (- <span className="text-[10px] text-neutral-600">—</span>- )}- </div>- </div>- <div className="flex items-center justify-between gap-2">- <div className="flex items-center gap-2">- <span- className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[20px] text-center"- style={{ background: "rgba(255,255,255,0.05)" }}- >- O- </span>- <span className="text-[10px] text-neutral-400">Out-point</span>- </div>- <div className="flex items-center gap-1.5">- {outPoint !== null ? (- <>- <span className="font-mono text-[10px] text-neutral-300">- {formatTime(outPoint)}- </span>- <Tooltip label="Clear out-point">- <button- type="button"- onClick={() => setOutPoint(null)}- className="w-4 h-4 flex items-center justify-center rounded text-neutral-500 hover:text-neutral-200 transition-colors"- aria-label="Clear out-point"- >- <svg- width="8"- height="8"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2.5"- >- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- </Tooltip>- </>- ) : (- <span className="text-[10px] text-neutral-600">—</span>- )}- </div>- </div>- </div>- </div>- <div style={{ borderTop: "1px solid rgba(255,255,255,0.06)" }} />- {/* Shortcuts */}- <div className="px-3 pt-2.5 pb-3 flex flex-col gap-3">- {SHORTCUT_SECTIONS.map((section) => (- <div key={section.title}>- <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">- {section.title}- </p>- <div className="flex flex-col gap-1">- {section.hints.map((hint) => (- <div key={hint.key} className="flex items-center gap-3">- <span- className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[36px] text-center"- style={{ background: "rgba(255,255,255,0.05)" }}- >- {hint.key}- </span>- <span className="text-[10px] text-neutral-400">{hint.label}</span>- </div>- ))}- </div>- </div>- ))}- </div>- </div>- )}- </div>+ <ShortcutsPanel+ disabled={disabled}+ duration={duration}+ inPoint={inPoint}+ outPoint={outPoint}+ setInPoint={setInPoint}+ setOutPoint={setOutPoint}+ onSeek={onSeek}+ /></div>);});diff --git a/packages/studio/src/player/components/ShortcutsPanel.tsx b/packages/studio/src/player/components/ShortcutsPanel.tsxnew file mode 100644index 0000000000..c282c7ef12--- /dev/null+++ b/packages/studio/src/player/components/ShortcutsPanel.tsx@@ -0,0 +1,277 @@+import { useState, useCallback, useRef, useEffect, memo } from "react";+import { formatTime, frameToSeconds } from "../lib/time";+import { Tooltip } from "../../components/ui";++const SHORTCUT_SECTIONS = [+ {+ title: "Playback",+ hints: [+ { key: "Space", label: "Play / Pause" },+ { key: "J", label: "Play backward" },+ { key: "K", label: "Stop" },+ { key: "L", label: "Play forward" },+ { key: "M", label: "Toggle mute" },+ { key: "⇧L", label: "Toggle loop" },+ { key: "←/→", label: "Step 1 frame" },+ { key: "⇧←/⇧→", label: "Step 10 frames" },+ { key: "F", label: "Toggle fullscreen" },+ ],+ },+ {+ title: "Work area",+ hints: [+ { key: "I", label: "Set in-point" },+ { key: "⇧I", label: "Clear in-point" },+ { key: "O", label: "Set out-point" },+ { key: "⇧O", label: "Clear out-point" },+ { key: "A", label: "Jump to in-point" },+ { key: "E", label: "Jump to out-point" },+ ],+ },+] as const;++interface ShortcutsPanelProps {+ disabled: boolean;+ duration: number;+ inPoint: number | null;+ outPoint: number | null;+ setInPoint: (v: number | null) => void;+ setOutPoint: (v: number | null) => void;+ onSeek: (time: number) => void;+}++export const ShortcutsPanel = memo(function ShortcutsPanel({+ disabled,+ duration,+ inPoint,+ outPoint,+ setInPoint,+ setOutPoint,+ onSeek,+}: ShortcutsPanelProps) {+ const [showShortcuts, setShowShortcuts] = useState(false);+ const [jumpFrame, setJumpFrame] = useState("");+ const shortcutsPanelRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ if (!showShortcuts) return;+ const handleMouseDown = (e: MouseEvent) => {+ if (shortcutsPanelRef.current && !shortcutsPanelRef.current.contains(e.target as Node)) {+ setShowShortcuts(false);+ }+ };+ document.addEventListener("mousedown", handleMouseDown);+ return () => {+ document.removeEventListener("mousedown", handleMouseDown);+ };+ }, [showShortcuts]);++ const commitJumpFrame = useCallback(() => {+ if (disabled) return;+ const frame = Number.parseInt(jumpFrame, 10);+ if (!Number.isFinite(frame) || duration <= 0) return;+ onSeek(Math.min(duration, frameToSeconds(Math.max(0, frame))));+ }, [disabled, duration, jumpFrame, onSeek]);++ const handleJumpSubmit = useCallback(+ (e: React.FormEvent) => {+ e.preventDefault();+ commitJumpFrame();+ },+ [commitJumpFrame],+ );++ const handleJumpKeyDown = useCallback(+ (e: React.KeyboardEvent<HTMLInputElement>) => {+ if (e.key !== "Enter") return;+ e.preventDefault();+ commitJumpFrame();+ },+ [commitJumpFrame],+ );++ return (+ <div ref={shortcutsPanelRef} className="relative flex-shrink-0">+ <Tooltip label="Shortcuts and tools">+ <button+ type="button"+ onClick={() => setShowShortcuts((v) => !v)}+ className={`w-6 h-6 flex items-center justify-center rounded border transition-colors ${+ showShortcuts+ ? "border-neutral-600 text-neutral-200 bg-neutral-800"+ : "border-neutral-800 text-neutral-600 hover:text-neutral-300 hover:border-neutral-600"+ }`}+ aria-label="Shortcuts and tools"+ aria-expanded={showShortcuts}+ >+ <svg+ width="11"+ height="11"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.75"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ <rect x="2" y="4" width="20" height="16" rx="2" />+ <path d="M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M10 12h.01M14 12h.01M18 12h.01M8 16h8" />+ </svg>+ </button>+ </Tooltip>+ {showShortcuts && (+ <div+ className="absolute bottom-full right-0 mb-2 z-50 rounded-lg shadow-xl min-w-[220px] overflow-y-auto"+ style={{+ background: "#161618",+ border: "1px solid rgba(255,255,255,0.08)",+ maxHeight: "min(280px, calc(100vh - 80px))",+ }}+ >+ <div className="px-3 pt-3 pb-2.5">+ <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">+ Jump to frame+ </p>+ <form onSubmit={handleJumpSubmit} className="flex items-center gap-1.5">+ <input+ value={jumpFrame}+ onChange={(e) => setJumpFrame(e.target.value)}+ disabled={disabled}+ inputMode="numeric"+ pattern="[0-9]*"+ aria-label="Jump to frame"+ placeholder="frame number"+ className="h-6 flex-1 rounded border border-neutral-700 bg-neutral-900 px-2 text-[10px] font-mono tabular-nums text-neutral-200 outline-none transition-colors placeholder:text-neutral-600 focus:border-studio-accent/60"+ onKeyDown={handleJumpKeyDown}+ onBlur={commitJumpFrame}+ />+ <Tooltip label="Jump to frame">+ <button+ type="submit"+ disabled={disabled}+ className="h-6 px-2 rounded border border-neutral-700 text-[10px] text-neutral-300 transition-colors hover:border-neutral-500 hover:bg-neutral-800 disabled:opacity-40"+ >+ Go+ </button>+ </Tooltip>+ </form>+ </div>+ <div style={{ borderTop: "1px solid rgba(255,255,255,0.06)" }} />+ <div className="px-3 pt-2.5 pb-2">+ <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">+ Work area+ </p>+ <div className="flex flex-col gap-1">+ <div className="flex items-center justify-between gap-2">+ <div className="flex items-center gap-2">+ <span+ className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[20px] text-center"+ style={{ background: "rgba(255,255,255,0.05)" }}+ >+ I+ </span>+ <span className="text-[10px] text-neutral-400">In-point</span>+ </div>+ <div className="flex items-center gap-1.5">+ {inPoint !== null ? (+ <>+ <span className="font-mono text-[10px] text-neutral-300">+ {formatTime(inPoint)}+ </span>+ <Tooltip label="Clear in-point">+ <button+ type="button"+ onClick={() => setInPoint(null)}+ className="w-4 h-4 flex items-center justify-center rounded text-neutral-500 hover:text-neutral-200 transition-colors"+ aria-label="Clear in-point"+ >+ <svg+ width="8"+ height="8"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ >+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </Tooltip>+ </>+ ) : (+ <span className="text-[10px] text-neutral-600">—</span>+ )}+ </div>+ </div>+ <div className="flex items-center justify-between gap-2">+ <div className="flex items-center gap-2">+ <span+ className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[20px] text-center"+ style={{ background: "rgba(255,255,255,0.05)" }}+ >+ O+ </span>+ <span className="text-[10px] text-neutral-400">Out-point</span>+ </div>+ <div className="flex items-center gap-1.5">+ {outPoint !== null ? (+ <>+ <span className="font-mono text-[10px] text-neutral-300">+ {formatTime(outPoint)}+ </span>+ <Tooltip label="Clear out-point">+ <button+ type="button"+ onClick={() => setOutPoint(null)}+ className="w-4 h-4 flex items-center justify-center rounded text-neutral-500 hover:text-neutral-200 transition-colors"+ aria-label="Clear out-point"+ >+ <svg+ width="8"+ height="8"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ >+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </Tooltip>+ </>+ ) : (+ <span className="text-[10px] text-neutral-600">—</span>+ )}+ </div>+ </div>+ </div>+ </div>+ <div style={{ borderTop: "1px solid rgba(255,255,255,0.06)" }} />+ <div className="px-3 pt-2.5 pb-3 flex flex-col gap-3">+ {SHORTCUT_SECTIONS.map((section) => (+ <div key={section.title}>+ <p className="text-[9px] font-medium text-neutral-500 uppercase tracking-wider mb-1.5">+ {section.title}+ </p>+ <div className="flex flex-col gap-1">+ {section.hints.map((hint) => (+ <div key={hint.key} className="flex items-center gap-3">+ <span+ className="font-mono text-[10px] rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 min-w-[36px] text-center"+ style={{ background: "rgba(255,255,255,0.05)" }}+ >+ {hint.key}+ </span>+ <span className="text-[10px] text-neutral-400">{hint.label}</span>+ </div>+ ))}+ </div>+ </div>+ ))}+ </div>+ </div>+ )}+ </div>+ );+});diff --git a/packages/studio/src/player/components/SpeedMenu.tsx b/packages/studio/src/player/components/SpeedMenu.tsxnew file mode 100644index 0000000000..be4497aa5e--- /dev/null+++ b/packages/studio/src/player/components/SpeedMenu.tsx@@ -0,0 +1,83 @@+import { useState, useRef, useEffect, memo } from "react";+import { trackStudioEvent } from "../../utils/studioTelemetry";+import { Tooltip } from "../../components/ui";++const SPEED_OPTIONS = [0.25, 0.5, 1, 1.5, 2] as const;++interface SpeedMenuProps {+ playbackRate: number;+ setPlaybackRate: (rate: number) => void;+ disabled: boolean;+}++export const SpeedMenu = memo(function SpeedMenu({+ playbackRate,+ setPlaybackRate,+ disabled,+}: SpeedMenuProps) {+ const [showSpeedMenu, setShowSpeedMenu] = useState(false);+ const speedMenuContainerRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ if (!showSpeedMenu) return;+ const handleMouseDown = (e: MouseEvent) => {+ if (+ speedMenuContainerRef.current &&+ !speedMenuContainerRef.current.contains(e.target as Node)+ ) {+ setShowSpeedMenu(false);+ }+ };+ document.addEventListener("mousedown", handleMouseDown);+ return () => {+ document.removeEventListener("mousedown", handleMouseDown);+ };+ }, [showSpeedMenu]);++ return (+ <div ref={speedMenuContainerRef} className="relative flex-shrink-0">+ <Tooltip label="Playback speed">+ <button+ type="button"+ onClick={() => setShowSpeedMenu((v) => !v)}+ disabled={disabled}+ className="w-10 px-2 py-1 rounded-md text-[10px] font-mono tabular-nums transition-colors"+ style={{ color: "#71717A", background: "rgba(255,255,255,0.04)" }}+ >+ {playbackRate === 1 ? "1x" : `${playbackRate}x`}+ </button>+ </Tooltip>+ {showSpeedMenu && (+ <div+ className="absolute bottom-full right-0 mb-1.5 rounded-lg shadow-xl z-50 min-w-[56px] overflow-hidden"+ style={{ background: "#161618", border: "1px solid rgba(255,255,255,0.08)" }}+ >+ {SPEED_OPTIONS.map((rate) => (+ <button+ key={rate}+ onClick={() => {+ trackStudioEvent("playback", { action: "speed_change", rate });+ setPlaybackRate(rate);+ setShowSpeedMenu(false);+ }}+ className="block w-full px-3 py-1.5 text-[11px] text-left font-mono tabular-nums transition-colors"+ style={{+ color: rate === playbackRate ? "#FAFAFA" : "#71717A",+ background: rate === playbackRate ? "rgba(255,255,255,0.06)" : "transparent",+ }}+ onMouseEnter={(e) => {+ if (rate !== playbackRate)+ e.currentTarget.style.background = "rgba(255,255,255,0.04)";+ }}+ onMouseLeave={(e) => {+ if (rate !== playbackRate) e.currentTarget.style.background = "transparent";+ }}+ >+ {rate}x+ </button>+ ))}+ </div>+ )}+ </div>+ );+});diff --git a/packages/studio/src/player/components/useSeekBarDrag.ts b/packages/studio/src/player/components/useSeekBarDrag.tsnew file mode 100644index 0000000000..81c78d1f1a--- /dev/null+++ b/packages/studio/src/player/components/useSeekBarDrag.ts@@ -0,0 +1,168 @@+import { useCallback } from "react";+import { useMountEffect } from "../../hooks/useMountEffect";+import { formatFrameTime, formatTime } from "../lib/time";+import { usePlayerStore, liveTime } from "../store/playerStore";++const SEEK_EDGE_SNAP_PX = 8;++export function resolveSeekPercent(clientX: number, rectLeft: number, rectWidth: number): number {+ if (!Number.isFinite(rectWidth) || rectWidth <= 0) return 0;+ const rawPercent = (clientX - rectLeft) / rectWidth;+ const clamped = Math.max(0, Math.min(1, rawPercent));+ const snapThreshold = Math.min(0.5, SEEK_EDGE_SNAP_PX / rectWidth);+ if (clamped <= snapThreshold) return 0;+ if (clamped >= 1 - snapThreshold) return 1;+ return clamped;+}++interface SeekBarRefs {+ seekBarRef: React.RefObject<HTMLDivElement | null>;+ progressFillRef: React.RefObject<HTMLDivElement | null>;+ progressThumbRef: React.RefObject<HTMLDivElement | null>;+ sliderRef: React.RefObject<HTMLDivElement | null>;+ timeDisplayRef: React.RefObject<HTMLSpanElement | null>;+ isDraggingRef: React.MutableRefObject<boolean>;+ durationRef: React.MutableRefObject<number>;+ currentTimeRef: React.MutableRefObject<number>;+ timeDisplayModeRef: React.MutableRefObject<"time" | "frame">;+}++function updateProgressUI(+ fillRef: React.RefObject<HTMLDivElement | null>,+ thumbRef: React.RefObject<HTMLDivElement | null>,+ pct: number,+): void {+ if (fillRef.current) fillRef.current.style.width = `${pct}%`;+ if (thumbRef.current) thumbRef.current.style.left = `${pct}%`;+}++export function useSeekBarDrag(+ refs: SeekBarRefs,+ onSeek: (time: number) => void,+ disabled: boolean,+ duration: number,+) {+ const seekFromClientX = useCallback(+ (clientX: number) => {+ if (disabled) return;+ const bar = refs.seekBarRef.current;+ if (!bar || duration <= 0) return;+ const rect = bar.getBoundingClientRect();+ const percent = resolveSeekPercent(clientX, rect.left, rect.width);+ updateProgressUI(refs.progressFillRef, refs.progressThumbRef, percent * 100);+ onSeek(percent * duration);+ },+ [disabled, duration, onSeek, refs],+ );++ const handlePointerDown = useCallback(+ (e: React.PointerEvent<HTMLDivElement>) => {+ if (e.button !== 0) return;+ e.preventDefault();+ e.currentTarget.focus();+ refs.isDraggingRef.current = true;++ const target = e.currentTarget;+ const pointerId = e.pointerId;+ try {+ target.setPointerCapture(pointerId);+ } catch {+ /* fallback to window listeners */+ }++ seekFromClientX(e.clientX);++ let seekRafId = 0;+ let pendingClientX = e.clientX;+ const onMove = (ev: PointerEvent) => {+ if (ev.pointerId !== pointerId || !refs.isDraggingRef.current) return;+ pendingClientX = ev.clientX;+ const bar = refs.seekBarRef.current;+ const dur = refs.durationRef.current;+ if (bar && dur > 0) {+ const rect = bar.getBoundingClientRect();+ const pct = resolveSeekPercent(ev.clientX, rect.left, rect.width) * 100;+ updateProgressUI(refs.progressFillRef, refs.progressThumbRef, pct);+ }+ if (!seekRafId) {+ seekRafId = requestAnimationFrame(() => {+ seekRafId = 0;+ if (refs.isDraggingRef.current) seekFromClientX(pendingClientX);+ });+ }+ };+ const cleanup = () => {+ refs.isDraggingRef.current = false;+ if (seekRafId) {+ cancelAnimationFrame(seekRafId);+ seekRafId = 0;+ }+ seekFromClientX(pendingClientX);+ try {+ target.releasePointerCapture(pointerId);+ } catch {+ /* already released */+ }+ target.removeEventListener("pointermove", onMove);+ target.removeEventListener("pointerup", onUp);+ target.removeEventListener("pointercancel", onUp);+ window.removeEventListener("pointerup", onUp);+ window.removeEventListener("pointercancel", onUp);+ document.removeEventListener("visibilitychange", onVisibilityChange);+ window.removeEventListener("blur", cleanup);+ };+ const onUp = (ev: PointerEvent) => {+ if (ev.pointerId !== pointerId) return;+ cleanup();+ };+ const onVisibilityChange = () => {+ if (document.visibilityState === "hidden") cleanup();+ };++ target.addEventListener("pointermove", onMove);+ target.addEventListener("pointerup", onUp);+ target.addEventListener("pointercancel", onUp);+ window.addEventListener("pointerup", onUp);+ window.addEventListener("pointercancel", onUp);+ document.addEventListener("visibilitychange", onVisibilityChange);+ window.addEventListener("blur", cleanup);+ },+ [seekFromClientX, refs],+ );++ useMountEffect(() => {+ const updateProgress = (t: number) => {+ refs.currentTimeRef.current = t;+ const dur = refs.durationRef.current;+ const pct = dur > 0 ? Math.min(100, (t / dur) * 100) : 0;+ updateProgressUI(refs.progressFillRef, refs.progressThumbRef, pct);+ if (refs.timeDisplayRef.current) {+ refs.timeDisplayRef.current.textContent =+ refs.timeDisplayModeRef.current === "frame" ? formatFrameTime(t, dur) : formatTime(t);+ }+ if (refs.sliderRef.current)+ refs.sliderRef.current.setAttribute("aria-valuenow", String(Math.round(t)));+ };+ const unsub = liveTime.subscribe(updateProgress);+ updateProgress(usePlayerStore.getState().currentTime);++ const interval = setInterval(() => {+ const t = usePlayerStore.getState().currentTime;+ const dur = usePlayerStore.getState().duration;+ if (dur > 0 && t > 0) {+ updateProgressUI(+ refs.progressFillRef,+ refs.progressThumbRef,+ Math.min(100, (t / dur) * 100),+ );+ }+ }, 500);++ return () => {+ unsub();+ clearInterval(interval);+ };+ });++ return { handlePointerDown };+}diff --git a/packages/studio/src/utils/timelineAssetDrop.test.ts b/packages/studio/src/utils/timelineAssetDrop.test.tsindex 9e59090396..046c5eba9f 100644--- a/packages/studio/src/utils/timelineAssetDrop.test.ts+++ b/packages/studio/src/utils/timelineAssetDrop.test.ts@@ -156,6 +156,6 @@ describe("insertTimelineAssetIntoSource", () => {);expect(html).toContain('data-composition-id="main">');- expect(html).toContain('<img id="photo_asset"');+ expect(html).toContain('<img id="photo_asset" data-start="0" data-duration="3" />');});});