@hyperframes/studio 0.7.61 → 0.7.62

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 (84) hide show
  1. package/dist/assets/{hyperframes-player-Xvx2hkrc.js → hyperframes-player-CWpmBjzv.js} +1 -1
  2. package/dist/assets/{index-BCpoiv9S.js → index-BJzSiIBj.js} +1 -1
  3. package/dist/assets/index-Ceyz8Qt2.css +1 -0
  4. package/dist/assets/{index-D-uFclFj.js → index-DJQPB78e.js} +1 -1
  5. package/dist/assets/index-vDRVQtTK.js +426 -0
  6. package/dist/index.d.ts +12 -1
  7. package/dist/index.html +2 -2
  8. package/dist/index.js +3504 -2955
  9. package/dist/index.js.map +1 -1
  10. package/package.json +7 -7
  11. package/src/App.tsx +15 -10
  12. package/src/components/EditorShell.tsx +12 -0
  13. package/src/components/StudioLeftSidebar.tsx +3 -0
  14. package/src/components/editor/DomEditSelectionChrome.test.tsx +51 -0
  15. package/src/components/editor/PropertyPanelFlat.tsx +6 -0
  16. package/src/components/editor/compositionReliabilityFixture.integration.test.ts +105 -0
  17. package/src/components/editor/domEditing.test.ts +34 -0
  18. package/src/components/editor/propertyPanelColor.test.tsx +31 -0
  19. package/src/components/editor/propertyPanelColor.tsx +150 -28
  20. package/src/components/editor/propertyPanelCommitField.tsx +178 -0
  21. package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +34 -0
  22. package/src/components/editor/propertyPanelFlatPrimitives.tsx +3 -0
  23. package/src/components/editor/propertyPanelFlatStyleSections.test.tsx +5 -1
  24. package/src/components/editor/propertyPanelFlatStyleSections.tsx +6 -0
  25. package/src/components/editor/propertyPanelFlatTextSection.test.tsx +47 -4
  26. package/src/components/editor/propertyPanelFlatTextSection.tsx +8 -0
  27. package/src/components/editor/propertyPanelInputCoverage.test.tsx +4 -1
  28. package/src/components/editor/propertyPanelPrimitives.tsx +3 -100
  29. package/src/components/editor/propertyPanelSections.tsx +2 -2
  30. package/src/components/editor/propertyPanelTypes.ts +2 -0
  31. package/src/components/editor/useInspectorGestureTransaction.test.tsx +37 -0
  32. package/src/components/editor/useInspectorGestureTransaction.ts +60 -0
  33. package/src/components/nle/TimelinePane.tsx +6 -0
  34. package/src/components/sidebar/CompositionsTab.drag.test.tsx +87 -0
  35. package/src/components/sidebar/CompositionsTab.tsx +45 -2
  36. package/src/components/sidebar/LeftSidebar.tsx +3 -0
  37. package/src/contexts/StudioContext.tsx +4 -0
  38. package/src/hooks/timelineEditingHelpers.ts +10 -4
  39. package/src/hooks/usePreviewPersistence.ts +7 -1
  40. package/src/hooks/useRazorSplit.history.test.tsx +21 -28
  41. package/src/hooks/useRazorSplit.test.tsx +20 -9
  42. package/src/hooks/useRazorSplit.testHelpers.ts +34 -22
  43. package/src/hooks/useRazorSplit.ts +78 -350
  44. package/src/hooks/useTimelineAddAtPlayhead.ts +15 -0
  45. package/src/hooks/useTimelineAssetDropOps.ts +52 -2
  46. package/src/hooks/useTimelineEditing.ts +19 -17
  47. package/src/hooks/useTimelineGroupEditing.ts +6 -7
  48. package/src/player/components/Timeline.tsx +12 -1
  49. package/src/player/components/timelineAuthoredMoveTarget.ts +77 -0
  50. package/src/player/components/timelineAuthoredTrack.ts +29 -0
  51. package/src/player/components/timelineCallbacks.ts +4 -0
  52. package/src/player/components/timelineClipDragCommit.test.ts +176 -0
  53. package/src/player/components/timelineClipDragCommit.ts +77 -105
  54. package/src/player/components/timelineClipDragPreview.test.ts +33 -1
  55. package/src/player/components/timelineClipDragPreview.ts +2 -1
  56. package/src/player/components/timelineCollision.test.ts +18 -0
  57. package/src/player/components/timelineCollision.ts +12 -9
  58. package/src/player/components/timelineDragDrop.ts +28 -7
  59. package/src/player/components/timelineEditCapabilities.ts +4 -1
  60. package/src/player/components/timelineGroupEditing.test.ts +10 -0
  61. package/src/player/components/timelineGroupEditing.ts +4 -3
  62. package/src/player/components/timelineLaneMoveRefresh.ts +14 -0
  63. package/src/player/components/timelineLayout.ts +3 -1
  64. package/src/player/components/timelineZMirror.ts +1 -1
  65. package/src/player/components/useTimelineClipDrag.ts +5 -0
  66. package/src/player/components/useTimelineEditPinning.ts +12 -0
  67. package/src/player/hooks/useExpandedTimelineElements.test.ts +42 -0
  68. package/src/player/hooks/useExpandedTimelineElements.ts +3 -0
  69. package/src/player/lib/playbackTypes.ts +2 -0
  70. package/src/player/lib/timelineDOM.test.ts +58 -0
  71. package/src/player/lib/timelineDOM.ts +18 -1
  72. package/src/player/lib/timelineElementHelpers.ts +21 -11
  73. package/src/player/store/playerStore.ts +2 -1
  74. package/src/utils/razorSplitTransaction.test.ts +175 -0
  75. package/src/utils/razorSplitTransaction.ts +200 -0
  76. package/src/utils/studioPreviewHelpers.test.ts +27 -0
  77. package/src/utils/timelineCompositionDrop.test.ts +12 -0
  78. package/src/utils/timelineCompositionDrop.ts +16 -0
  79. package/src/utils/timelineCompositionInsert.test.ts +142 -0
  80. package/src/utils/timelineCompositionInsert.ts +90 -0
  81. package/src/utils/timelineElementSplit.test.ts +14 -2
  82. package/src/utils/timelineElementSplit.ts +5 -1
  83. package/dist/assets/index-2mxh_HSy.js +0 -426
  84. package/dist/assets/index-BhWig0mx.css +0 -1
@@ -0,0 +1,90 @@
1
+ import { createStudioSaveHttpError } from "./studioSaveDiagnostics";
2
+ import { serializeStudioFileMutation } from "./studioFileMutationCoordinator";
3
+ import type { RecordEditInput } from "./studioFileHistory";
4
+ import { buildProjectApiPath } from "./projectRouting";
5
+
6
+ interface TimelineCompositionInsertionResult {
7
+ path: string;
8
+ hostId: string;
9
+ before: string;
10
+ after: string;
11
+ version: string;
12
+ }
13
+
14
+ async function insertTimelineComposition(input: {
15
+ projectId: string;
16
+ targetPath: string;
17
+ sourcePath: string;
18
+ start: number;
19
+ track: number;
20
+ }): Promise<TimelineCompositionInsertionResult> {
21
+ const current = await fetch(
22
+ buildProjectApiPath(input.projectId, `/files/${encodeURIComponent(input.targetPath)}`),
23
+ );
24
+ if (!current.ok) {
25
+ throw await createStudioSaveHttpError(current, `Failed to read ${input.targetPath}`);
26
+ }
27
+ const snapshot = (await current.json()) as { version?: string };
28
+ if (typeof snapshot.version !== "string") throw new Error("Missing composition file version");
29
+
30
+ const response = await fetch(
31
+ buildProjectApiPath(
32
+ input.projectId,
33
+ `/file-mutations/insert-composition/${encodeURIComponent(input.targetPath)}`,
34
+ ),
35
+ {
36
+ method: "POST",
37
+ headers: { "Content-Type": "application/json" },
38
+ body: JSON.stringify({
39
+ sourcePath: input.sourcePath,
40
+ start: input.start,
41
+ track: input.track,
42
+ expectedVersion: snapshot.version,
43
+ }),
44
+ },
45
+ );
46
+ if (!response.ok) {
47
+ throw await createStudioSaveHttpError(response, "Failed to add composition to timeline");
48
+ }
49
+ return (await response.json()) as TimelineCompositionInsertionResult;
50
+ }
51
+
52
+ export async function commitTimelineCompositionInsertion(input: {
53
+ projectId: string;
54
+ targetPath: string;
55
+ sourcePath: string;
56
+ start: number;
57
+ track: number;
58
+ writeFile: (path: string, content: string, expectedContent?: string) => Promise<void>;
59
+ recordEdit: (entry: RecordEditInput) => Promise<void>;
60
+ observeVersion?: (path: string, version: string | null) => void;
61
+ selectHost: (key: string) => void;
62
+ resync?: () => void;
63
+ refresh: () => void;
64
+ }): Promise<void> {
65
+ await serializeStudioFileMutation(input.writeFile, input.targetPath, async () => {
66
+ const result = await insertTimelineComposition(input);
67
+ input.observeVersion?.(input.targetPath, result.version);
68
+ try {
69
+ await input.recordEdit({
70
+ label: "Add composition to timeline",
71
+ kind: "timeline",
72
+ files: { [input.targetPath]: { before: result.before, after: result.after } },
73
+ });
74
+ } catch (error) {
75
+ await input.writeFile(input.targetPath, result.before, result.after);
76
+ throw error;
77
+ }
78
+ input.selectHost(`${input.targetPath}#${result.hostId}`);
79
+ try {
80
+ input.resync?.();
81
+ } catch (error) {
82
+ console.error("[Studio] Composition insertion committed but preview resync failed", error);
83
+ }
84
+ try {
85
+ input.refresh();
86
+ } catch (error) {
87
+ console.error("[Studio] Composition insertion committed but refresh failed", error);
88
+ }
89
+ });
90
+ }
@@ -14,6 +14,7 @@ function element(overrides: Partial<TimelineElement> = {}): TimelineElement {
14
14
  start: 1,
15
15
  duration: 4,
16
16
  track: 0,
17
+ domId: "el-1",
17
18
  ...overrides,
18
19
  };
19
20
  }
@@ -77,10 +78,21 @@ describe("canSplitElementAt", () => {
77
78
  ).toBe(false);
78
79
  });
79
80
 
80
- it("rejects locked, implicit and sub-composition elements", () => {
81
+ it("rejects locked and implicit elements while allowing identified compositions", () => {
81
82
  expect(canSplitElementAt(element({ timelineLocked: true }), 3)).toBe(false);
82
83
  expect(canSplitElementAt(element({ timingSource: "implicit" }), 3)).toBe(false);
83
- expect(canSplitElementAt(element({ compositionSrc: "child.html" }), 3)).toBe(false);
84
+ expect(
85
+ canSplitElementAt(
86
+ element({ kind: "composition", compositionSrc: "child.html", playbackRate: 2 }),
87
+ 3,
88
+ ),
89
+ ).toBe(true);
90
+ });
91
+
92
+ it("rejects missing identity and invalid playback rates", () => {
93
+ expect(canSplitElementAt(element({ domId: undefined }), 3)).toBe(false);
94
+ expect(canSplitElementAt(element({ playbackRate: 0 }), 3)).toBe(false);
95
+ expect(canSplitElementAt(element({ playbackRate: Number.NaN }), 3)).toBe(false);
84
96
  });
85
97
  });
86
98
 
@@ -22,10 +22,14 @@ export function isSplitTimeWithinBounds(
22
22
  }
23
23
 
24
24
  export function canSplitElement(el: TimelineElement): boolean {
25
+ const hasStableIdentity = Boolean(el.hfId || el.domId || el.selector);
26
+ const hasValidRate =
27
+ el.playbackRate == null || (Number.isFinite(el.playbackRate) && el.playbackRate > 0);
25
28
  return (
26
29
  !el.timelineLocked &&
27
30
  el.timingSource !== "implicit" &&
28
- !el.compositionSrc &&
31
+ hasStableIdentity &&
32
+ hasValidRate &&
29
33
  !!el.duration &&
30
34
  Number.isFinite(el.duration)
31
35
  );