@hyperframes/studio 0.9.51 → 0.9.53
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.
- package/dist/assets/{hyperframes-player-i4dtJlrd.js → hyperframes-player-z7r-N5fm.js} +2 -2
- package/dist/assets/{index-Be_pDhIw.js → index-2QPHxCxy.js} +1 -1
- package/dist/assets/{index-CU24FmKd.css → index-CRiuMxyq.css} +1 -1
- package/dist/assets/{index-Dvlt50yp.js → index-Dpo7Q_9-.js} +160 -160
- package/dist/assets/index-Dv67Vrl6.js +74 -0
- package/dist/assets/{pausedVideoDecoder-C_20YkSR.js → pausedVideoDecoder-BarDYEAf.js} +1 -1
- package/dist/{chunk-67DSVBEI.js → chunk-F6EHWNZU.js} +1 -1
- package/dist/{chunk-ZNUWV4FN.js → chunk-G6FJSL7X.js} +16 -8
- package/dist/chunk-USW3YBOG.js +70 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.html +2 -2
- package/dist/index.js +49 -79
- package/dist/keys.d.ts +72 -1
- package/dist/keys.js +5 -4
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/ui.d.ts +3 -1
- package/dist/ui.js +3 -1
- package/package.json +9 -9
- package/src/captions/keyboard.ts +1 -1
- package/src/components/RightPanelTabs.test.tsx +1 -1
- package/src/components/StudioHeader.dom.test.tsx +1 -1
- package/src/components/TimelineHistoryButtons.dom.test.tsx +1 -1
- package/src/components/TimelineToolbar.tsx +1 -1
- package/src/components/editor/SnapToolbar.tsx +1 -1
- package/src/components/editor/useDomEditNudge.ts +1 -1
- package/src/components/panels/SlideshowPanel.tsx +1 -1
- package/src/components/renders/RenderQueue.test.tsx +1 -1
- package/src/components/ui/Button.test.tsx +1 -1
- package/src/components/ui/Menu.test.tsx +6 -4
- package/src/components/ui/Menu.tsx +8 -5
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/valueControls.test.tsx +1 -1
- package/src/hooks/appHotkeysDispatch.ts +1 -1
- package/src/hooks/linkShortcuts.ts +1 -1
- package/src/hooks/useAutomationSelectionKeyboard.ts +1 -1
- package/src/hooks/useKeyframeKeyboard.ts +1 -1
- package/src/index.ts +2 -2
- package/src/keys.test.ts +5 -7
- package/src/keys.ts +1 -6
- package/src/player/components/ShortcutsPanel.tsx +1 -1
- package/src/player/components/studioCombo.test.ts +1 -1
- package/src/player/components/studioShortcuts.ts +1 -1
- package/src/player/lib/playbackShortcuts.ts +3 -28
- package/src/ui.ts +1 -0
- package/src/utils/studioHelpers.ts +1 -1
- package/src/utils/studioPendingEdits.ts +1 -1
- package/src/utils/timelineDiscovery.ts +1 -1
- package/src/utils/typingTarget.test.ts +1 -1
- package/src/webmcp/polyfill.transport.test.ts +13 -3
- package/src/webmcp/types.ts +3 -3
- package/src/webmcp/useStudioAgentTools.polyfill.test.tsx +89 -121
- package/src/webmcp/useStudioAgentTools.test.tsx +2 -2
- package/src/webmcp/useStudioAgentTools.ts +2 -3
- package/dist/assets/index-BX3KHhGX.js +0 -71
- package/dist/chunk-5ZHKYODQ.js +0 -149
- package/dist/keys-B163OjLN.d.ts +0 -87
- package/src/player/components/studioCombo.ts +0 -108
- package/src/utils/typingTarget.ts +0 -56
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
* Drives the write tools through the REAL `@mcp-b/global` package rather than
|
|
4
4
|
* a fake `document.modelContext`.
|
|
5
5
|
*
|
|
6
|
-
* The package
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* of 'undefined'" while the read tools kept working. This file proves the fix
|
|
13
|
-
* against the code that ships in the polyfill chunk. The spec-shaped call and
|
|
14
|
-
* the abort path live in `useStudioAgentTools.test.tsx`; the polyfill cannot
|
|
15
|
-
* exercise them because it drops the caller's signal before the handler.
|
|
16
|
-
*
|
|
17
|
-
* A native-looking `modelContext` is installed BEFORE the import so the bridge
|
|
18
|
-
* wraps it and mirrors every registration into it, which is how both paths get
|
|
19
|
-
* covered from one setup. Its own file because the import is a one-shot side
|
|
20
|
-
* effect that the sibling suite's fake would otherwise have to fight.
|
|
6
|
+
* The package installs the W3C polyfill and wraps it in an in-page MCP server
|
|
7
|
+
* that an out-of-browser agent reaches over the tab transport. This file
|
|
8
|
+
* proves a write tool saves when an MCP `tools/call` drives it through that
|
|
9
|
+
* chain, against the code that ships in the polyfill chunk. Its own file
|
|
10
|
+
* because the import is a one-shot side effect that the sibling suite's fake
|
|
11
|
+
* would otherwise have to fight.
|
|
21
12
|
*/
|
|
22
13
|
import { act } from "react";
|
|
23
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
afterAll,
|
|
16
|
+
afterEach,
|
|
17
|
+
beforeAll,
|
|
18
|
+
describe,
|
|
19
|
+
expect,
|
|
20
|
+
it,
|
|
21
|
+
vi,
|
|
22
|
+
type MockInstance,
|
|
23
|
+
} from "vitest";
|
|
24
24
|
import { mountReactHarness } from "../hooks/domSelectionTestHarness";
|
|
25
25
|
import { mintElementHandle } from "./handles";
|
|
26
26
|
import { useStudioAgentTools, type StudioAgentToolsDeps } from "./useStudioAgentTools";
|
|
@@ -30,71 +30,37 @@ vi.mock("../telemetry/client", () => ({ trackEvent: vi.fn() }));
|
|
|
30
30
|
|
|
31
31
|
Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", true);
|
|
32
32
|
|
|
33
|
-
/** What a browser's own `registerTool` receives from the bridge. */
|
|
34
|
-
interface MirroredTool {
|
|
35
|
-
name: string;
|
|
36
|
-
description: string;
|
|
37
|
-
execute: (input: object, options?: { signal?: AbortSignal }) => Promise<unknown>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** What `getTools()` returns and `executeTool()` accepts. */
|
|
41
|
-
interface RegisteredTool {
|
|
42
|
-
name: string;
|
|
43
|
-
description: string;
|
|
44
|
-
window: Window;
|
|
45
|
-
origin: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** The bridge's registry entry, as the reporter of the bug drove it. */
|
|
49
|
-
interface BridgeToolEntry {
|
|
50
|
-
item: { name: string };
|
|
51
|
-
execute: (input: object, signal?: AbortSignal) => Promise<unknown>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
33
|
interface BridgeModelContext {
|
|
55
|
-
|
|
56
|
-
getTools(): Promise<
|
|
57
|
-
executeTool(
|
|
58
|
-
tool: RegisteredTool,
|
|
59
|
-
inputArguments: string,
|
|
60
|
-
options?: { signal?: AbortSignal },
|
|
61
|
-
): Promise<string | null>;
|
|
34
|
+
listTools(): { name: string }[];
|
|
35
|
+
getTools(): Promise<{ name: string }[]>;
|
|
62
36
|
}
|
|
63
37
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
// The bridge delegates `getTools()` to the native context when there is one,
|
|
71
|
-
// and its own `executeTool` then insists on a full `RegisteredTool`.
|
|
72
|
-
getTools: async (): Promise<RegisteredTool[]> =>
|
|
73
|
-
mirrored.map((tool) => ({
|
|
74
|
-
name: tool.name,
|
|
75
|
-
description: tool.description,
|
|
76
|
-
window,
|
|
77
|
-
origin: window.location.origin,
|
|
78
|
-
})),
|
|
79
|
-
};
|
|
38
|
+
interface JsonRpcResponse {
|
|
39
|
+
id: number;
|
|
40
|
+
result?: { structuredContent?: unknown; content?: { type: string; text?: string }[] };
|
|
41
|
+
error?: unknown;
|
|
42
|
+
}
|
|
80
43
|
|
|
81
44
|
let cleanup: (() => void) | null = null;
|
|
82
45
|
|
|
83
46
|
beforeAll(async () => {
|
|
84
|
-
//
|
|
85
|
-
Object.defineProperty(
|
|
86
|
-
value: fakeNative,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true,
|
|
89
|
-
});
|
|
47
|
+
// jsdom leaves this undefined and the polyfill installs only in a secure context.
|
|
48
|
+
Object.defineProperty(window, "isSecureContext", { value: true, configurable: true });
|
|
90
49
|
await import("@mcp-b/global");
|
|
91
|
-
expect(
|
|
50
|
+
expect(typeof bridge().listTools).toBe("function");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterAll(async () => {
|
|
54
|
+
// Close the server so its deferred tools-changed event doesn't fire after jsdom is torn down.
|
|
55
|
+
const { cleanupWebModelContext } = await import("@mcp-b/global");
|
|
56
|
+
cleanupWebModelContext();
|
|
57
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
58
|
+
Reflect.deleteProperty(window, "isSecureContext");
|
|
92
59
|
});
|
|
93
60
|
|
|
94
61
|
afterEach(async () => {
|
|
95
62
|
cleanup?.();
|
|
96
63
|
cleanup = null;
|
|
97
|
-
mirrored.length = 0;
|
|
98
64
|
// The polyfill watches the document with a MutationObserver that reads jsdom
|
|
99
65
|
// globals. Empty the document and let the observer settle now, while those
|
|
100
66
|
// globals still exist, instead of when vitest closes the window.
|
|
@@ -112,28 +78,14 @@ function bridge(): BridgeModelContext {
|
|
|
112
78
|
/** Registration is async, so wait for the whole tool set to land. */
|
|
113
79
|
async function waitForTools(count: number): Promise<void> {
|
|
114
80
|
const deadline = Date.now() + 5_000;
|
|
115
|
-
while (bridge().
|
|
81
|
+
while (bridge().listTools().length !== count || (await bridge().getTools()).length !== count) {
|
|
116
82
|
if (Date.now() > deadline) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
`expected ${count} tools, saw ${bridge().tools.size} in the bridge and ${mirrored.length} mirrored`,
|
|
119
|
-
);
|
|
83
|
+
throw new Error(`expected ${count} tools, saw ${bridge().listTools().length} in the bridge`);
|
|
120
84
|
}
|
|
121
85
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
122
86
|
}
|
|
123
87
|
}
|
|
124
88
|
|
|
125
|
-
function bridgeEntry(name: string): BridgeToolEntry {
|
|
126
|
-
const entry = [...bridge().tools.values()].find((candidate) => candidate.item.name === name);
|
|
127
|
-
if (!entry) throw new Error(`expected ${name} in the bridge registry`);
|
|
128
|
-
return entry;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function mirroredTool(name: string): MirroredTool {
|
|
132
|
-
const tool = mirrored.find((candidate) => candidate.name === name);
|
|
133
|
-
if (!tool) throw new Error(`expected ${name} to be mirrored into the native context`);
|
|
134
|
-
return tool;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
89
|
/** Mount Studio's tools against a preview whose `#agent` element can be edited. */
|
|
138
90
|
async function mountEditableAgent() {
|
|
139
91
|
const doc = previewDoc('<h1 id="agent">Agent</h1>');
|
|
@@ -170,49 +122,65 @@ async function mountEditableAgent() {
|
|
|
170
122
|
return { agent, handle, setText };
|
|
171
123
|
}
|
|
172
124
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// Chromium's `executeTool` extension, which the bridge also implements.
|
|
185
|
-
const descriptor = (await bridge().getTools()).find((tool) => tool.name === "studio_set_text");
|
|
186
|
-
if (!descriptor) throw new Error("expected studio_set_text in getTools()");
|
|
187
|
-
const viaExecuteTool = await bridge().executeTool(
|
|
188
|
-
descriptor,
|
|
189
|
-
JSON.stringify({ handle, text: "Through executeTool" }),
|
|
190
|
-
{ signal: new AbortController().signal },
|
|
191
|
-
);
|
|
192
|
-
expect(JSON.parse(viaExecuteTool ?? "null")).toMatchObject({ ok: true, stage: "saved" });
|
|
125
|
+
/** Post one JSON-RPC message to the in-page server the way the tab client does. */
|
|
126
|
+
function postToServer(payload: object): void {
|
|
127
|
+
window.dispatchEvent(
|
|
128
|
+
new MessageEvent("message", {
|
|
129
|
+
data: { channel: "mcp-default", type: "mcp", direction: "client-to-server", payload },
|
|
130
|
+
origin: window.location.origin,
|
|
131
|
+
source: window,
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
193
135
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
136
|
+
/** The server answers through `window.postMessage`; wait for the reply to `id`. */
|
|
137
|
+
async function replyTo(sent: MockInstance, id: number): Promise<JsonRpcResponse> {
|
|
138
|
+
const deadline = Date.now() + 5_000;
|
|
139
|
+
for (;;) {
|
|
140
|
+
for (const [message] of sent.mock.calls) {
|
|
141
|
+
const payload = (message as { payload?: unknown } | undefined)?.payload;
|
|
142
|
+
if (typeof payload === "object" && payload !== null && Reflect.get(payload, "id") === id) {
|
|
143
|
+
return payload as JsonRpcResponse;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (Date.now() > deadline) throw new Error(`no MCP reply to request ${id}`);
|
|
147
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
201
150
|
|
|
202
|
-
|
|
151
|
+
describe("useStudioAgentTools through @mcp-b/global", () => {
|
|
152
|
+
it("saves through studio_set_text when an MCP client calls it", async () => {
|
|
203
153
|
const { agent, handle, setText } = await mountEditableAgent();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
154
|
+
const sent = vi.spyOn(window, "postMessage");
|
|
155
|
+
|
|
156
|
+
postToServer({
|
|
157
|
+
jsonrpc: "2.0",
|
|
158
|
+
id: 1,
|
|
159
|
+
method: "initialize",
|
|
160
|
+
params: {
|
|
161
|
+
protocolVersion: "2025-06-18",
|
|
162
|
+
capabilities: {},
|
|
163
|
+
clientInfo: { name: "studio-test", version: "1.0.0" },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
expect((await replyTo(sent, 1)).error).toBeUndefined();
|
|
167
|
+
postToServer({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
168
|
+
|
|
169
|
+
postToServer({
|
|
170
|
+
jsonrpc: "2.0",
|
|
171
|
+
id: 2,
|
|
172
|
+
method: "tools/call",
|
|
173
|
+
params: { name: "studio_set_text", arguments: { handle, text: "Through MCP" } },
|
|
174
|
+
});
|
|
175
|
+
const reply = await replyTo(sent, 2);
|
|
176
|
+
sent.mockRestore();
|
|
177
|
+
|
|
178
|
+
const text = reply.result?.content?.[0]?.text;
|
|
179
|
+
const result = reply.result?.structuredContent ?? JSON.parse(text ?? "null");
|
|
212
180
|
expect(result).toMatchObject({ ok: true, stage: "saved", changed: true });
|
|
213
181
|
expect(setText).toHaveBeenCalledWith(
|
|
214
182
|
expect.objectContaining({ element: agent }),
|
|
215
|
-
"Through
|
|
183
|
+
"Through MCP",
|
|
216
184
|
"self",
|
|
217
185
|
);
|
|
218
186
|
});
|
|
@@ -26,7 +26,7 @@ async function executeRegistered<T>(
|
|
|
26
26
|
return (await tool.execute(input, { signal })) as T;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** The call shape `@mcp-b/global`
|
|
29
|
+
/** The call shape `@mcp-b/global` used before 6.0: the input and nothing else. */
|
|
30
30
|
async function executeRegisteredWithoutOptions<T>(
|
|
31
31
|
registered: ModelContextTool[],
|
|
32
32
|
name: string,
|
|
@@ -362,7 +362,7 @@ describe("useStudioAgentTools", () => {
|
|
|
362
362
|
});
|
|
363
363
|
|
|
364
364
|
it("runs every write tool when execute is called with the input alone", async () => {
|
|
365
|
-
// `@mcp-b/global`
|
|
365
|
+
// `@mcp-b/global` before 6.0 invoked `execute(input)` with no options object, both from
|
|
366
366
|
// its in-page server and from the descriptor it mirrors into a native
|
|
367
367
|
// `document.modelContext`. Handlers that destructured `{ signal }` threw a
|
|
368
368
|
// TypeError before running, which `runToolBody` reports as `internal`.
|
|
@@ -117,9 +117,8 @@ export function buildStudioTools(depsRef: {
|
|
|
117
117
|
/**
|
|
118
118
|
* `execute` for a tool whose handler takes the caller's abort signal.
|
|
119
119
|
*
|
|
120
|
-
* The spec shape is `execute(input, { signal })`, but `@mcp-b/global`
|
|
121
|
-
*
|
|
122
|
-
* registered `execute` with the input ALONE, both from its in-page
|
|
120
|
+
* The spec shape is `execute(input, { signal })`, but `@mcp-b/global` before
|
|
121
|
+
* 6.0 invoked a registered `execute` with the input ALONE, both from its in-page
|
|
123
122
|
* `BrowserMcpServer` wrapper and from the descriptor it mirrors into a native
|
|
124
123
|
* `document.modelContext`. A handler that destructures its second argument
|
|
125
124
|
* throws before it runs, so every write tool failed with "Cannot destructure
|