@hyperframes/studio 0.9.30 → 0.9.32
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/{codec-B1UWDNJp.js → codec-Bz1jsLs8.js} +1 -1
- package/dist/assets/{hyperframes-player-DQd2VPm2.js → hyperframes-player-cdH5Sz_t.js} +1 -1
- package/dist/assets/{index-gkyTLE7n.js → index-D1l7izdf.js} +176 -176
- package/dist/assets/{index-B7CtVv8e.js → index-DFRbcd5J.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-Bfv1WSlz.js → pausedVideoDecoder-CgV8YB6S.js} +1 -1
- package/dist/{chunk-J3VJE463.js → chunk-52AJB4PN.js} +4 -1
- package/dist/{chunk-LRTUWOR4.js → chunk-YKBN653R.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +179 -204
- package/dist/player.js +2 -2
- package/dist/ui.js +1 -1
- package/package.json +8 -8
- package/src/components/sidebar/CompositionsTab.hoverPreview.test.tsx +100 -0
- package/src/components/sidebar/CompositionsTab.test.ts +2 -24
- package/src/components/sidebar/CompositionsTab.tsx +35 -100
- package/src/components/ui/Input.tsx +4 -1
- package/src/components/ui/valueControls.test.tsx +85 -0
- package/src/hooks/timelineAudioGroupCreate.ts +2 -1
- package/src/hooks/useGestureCommit.ts +2 -1
- package/src/hooks/useRazorSplit.ts +5 -1
- package/src/hooks/useTimelineDeleteOps.test.tsx +28 -0
- package/src/hooks/useTimelineDeleteOps.ts +4 -1
- package/src/utils/countOf.test.ts +10 -0
- package/src/utils/countOf.ts +3 -0
- package/src/webmcp/polyfill.transport.test.ts +59 -0
- package/src/webmcp/polyfill.ts +15 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/**
|
|
3
|
+
* Loads the REAL `@mcp-b/global` through Studio's loader, inside a page that is
|
|
4
|
+
* framed by another site, and checks that neither of the package's message
|
|
5
|
+
* transports answers anyone but Studio's own page.
|
|
6
|
+
*/
|
|
7
|
+
import { afterAll, expect, it, vi } from "vitest";
|
|
8
|
+
|
|
9
|
+
vi.mock("../telemetry/client", () => ({ trackEvent: vi.fn() }));
|
|
10
|
+
|
|
11
|
+
const framer = { postMessage: vi.fn() };
|
|
12
|
+
const ownParent = Object.getOwnPropertyDescriptor(window, "parent");
|
|
13
|
+
afterAll(() => {
|
|
14
|
+
if (ownParent) Object.defineProperty(window, "parent", ownParent);
|
|
15
|
+
else Reflect.deleteProperty(window, "parent");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const settle = () => new Promise((resolve) => setTimeout(resolve, 20));
|
|
19
|
+
|
|
20
|
+
it("answers no MCP client but Studio's own page when another site frames Studio", async () => {
|
|
21
|
+
Object.defineProperty(window, "parent", { value: framer, configurable: true });
|
|
22
|
+
const ownMessages = vi.spyOn(window, "postMessage");
|
|
23
|
+
const { loadModelContextPolyfill } = await import("./polyfill");
|
|
24
|
+
|
|
25
|
+
expect(await loadModelContextPolyfill()).not.toBeNull();
|
|
26
|
+
await settle();
|
|
27
|
+
expect(framer.postMessage).not.toHaveBeenCalled();
|
|
28
|
+
|
|
29
|
+
ownMessages.mockClear();
|
|
30
|
+
window.dispatchEvent(
|
|
31
|
+
new MessageEvent("message", {
|
|
32
|
+
data: {
|
|
33
|
+
channel: "mcp-default",
|
|
34
|
+
type: "mcp",
|
|
35
|
+
direction: "client-to-server",
|
|
36
|
+
payload: "mcp-check-ready",
|
|
37
|
+
},
|
|
38
|
+
origin: "https://other.example",
|
|
39
|
+
source: window,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
await settle();
|
|
43
|
+
expect(ownMessages).not.toHaveBeenCalled();
|
|
44
|
+
|
|
45
|
+
window.dispatchEvent(
|
|
46
|
+
new MessageEvent("message", {
|
|
47
|
+
data: {
|
|
48
|
+
channel: "mcp-default",
|
|
49
|
+
type: "mcp",
|
|
50
|
+
direction: "client-to-server",
|
|
51
|
+
payload: "mcp-check-ready",
|
|
52
|
+
},
|
|
53
|
+
origin: window.location.origin,
|
|
54
|
+
source: window,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
await settle();
|
|
58
|
+
expect(ownMessages).toHaveBeenCalled();
|
|
59
|
+
});
|
package/src/webmcp/polyfill.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* and so it lands in its own chunk rather than the entry bundle.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import type { WebModelContextInitOptions } from "@mcp-b/global";
|
|
15
16
|
import { makeStudioDebugLogger } from "../utils/studioDebug";
|
|
16
17
|
import { trackEvent } from "../telemetry/client";
|
|
17
18
|
import { getModelContext, type ModelContext } from "./types";
|
|
@@ -24,8 +25,22 @@ const log = makeStudioDebugLogger("webmcp");
|
|
|
24
25
|
*/
|
|
25
26
|
let pending: Promise<ModelContext | null> | null = null;
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Left to its defaults the package answers MCP messages from any origin, and from
|
|
30
|
+
* whatever page frames Studio. Only Studio's own page may be a client.
|
|
31
|
+
*/
|
|
32
|
+
function ownPageOnly(): WebModelContextInitOptions {
|
|
33
|
+
return {
|
|
34
|
+
transport: {
|
|
35
|
+
tabServer: { allowedOrigins: [window.location.origin] },
|
|
36
|
+
iframeServer: false,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
async function importPolyfill(): Promise<ModelContext | null> {
|
|
28
42
|
try {
|
|
43
|
+
window.__webModelContextOptions = ownPageOnly();
|
|
29
44
|
await import("@mcp-b/global");
|
|
30
45
|
const modelContext = getModelContext();
|
|
31
46
|
if (!modelContext) {
|