@hyperframes/studio 0.8.34 → 0.8.35

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.
@@ -8,7 +8,9 @@
8
8
  import { expect } from "vitest";
9
9
  import type { DomEditSelection } from "../components/editor/domEditingTypes";
10
10
  import type { ToolFailure, ToolResult } from "./toolResult";
11
+ import type { StudioLookSnapshot } from "./tools/lookTools";
11
12
  import type { SelectionToolDeps } from "./tools/selectionTools";
13
+ import type { StudioAgentToolsDeps } from "./useStudioAgentTools";
12
14
  import { mintElementHandle } from "./handles";
13
15
  import type { TargetedWriteDeps } from "./writeCoordinator";
14
16
 
@@ -126,3 +128,57 @@ export function expectFailure(result: ToolResult<unknown>): ToolFailure {
126
128
  if (result.ok) throw new Error("unreachable");
127
129
  return result;
128
130
  }
131
+
132
+ /** A Studio snapshot with nothing in it; override only what the test is about. */
133
+ export function lookSnapshot(overrides: Partial<StudioLookSnapshot> = {}): StudioLookSnapshot {
134
+ return {
135
+ projectId: "demo",
136
+ compositionPath: "index.html",
137
+ currentTime: 0,
138
+ duration: 10,
139
+ isPlaying: false,
140
+ elements: [],
141
+ scene: { status: "ready", items: [], drillInItem: null },
142
+ selection: null,
143
+ selectionAnimationCount: 0,
144
+ history: { canUndo: false, canRedo: false, undoLabel: null, redoLabel: null },
145
+ ...overrides,
146
+ };
147
+ }
148
+
149
+ /** Full `useStudioAgentTools` deps with inert defaults; override only what the test is about. */
150
+ export function studioAgentToolsDeps(
151
+ overrides: Partial<StudioAgentToolsDeps> = {},
152
+ ): StudioAgentToolsDeps {
153
+ return {
154
+ getSnapshot: () => lookSnapshot(),
155
+ getPreviewDocument: () => null,
156
+ buildSelection: async () => null,
157
+ applySelection: () => undefined,
158
+ requestSeek: () => undefined,
159
+ readPlayhead: () => ({ currentTime: 0, duration: 10, isPlaying: false }),
160
+ getProjectId: () => "demo",
161
+ getCompositionPath: () => "index.html",
162
+ probeFrame: async () => ({ ok: true, status: 200 }),
163
+ wait: async () => undefined,
164
+ getCurrentSelection: () => null,
165
+ getWriteBlockedReason: () => null,
166
+ setText: async () => ({ ok: true }),
167
+ setStyle: async () => ({ ok: true }),
168
+ readBox: () => ({ x: 0, y: 0, width: 100, height: 50 }),
169
+ moveTo: async () => undefined,
170
+ resizeTo: async () => undefined,
171
+ rotateTo: async () => undefined,
172
+ addAnimation: async () => true,
173
+ updateAnimation: async () => true,
174
+ addKeyframe: async () => undefined,
175
+ deleteAnimation: async () => true,
176
+ getAnimationsForSelection: async () => [],
177
+ getGsapDiagnostics: () => ({
178
+ animations: [],
179
+ multipleTimelines: false,
180
+ unsupportedTimelinePattern: false,
181
+ }),
182
+ ...overrides,
183
+ };
184
+ }