Skip to content

Commit 8bef024

Browse files
committed
sdk changes
1 parent 7dcaa53 commit 8bef024

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

src/app-bridge.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ describe("App <-> AppBridge integration", () => {
180180
await bridge.connect(bridgeTransport);
181181
});
182182

183-
it("app.sendSizeChange triggers bridge.onsizechange", async () => {
183+
it("app.sendSizeChanged triggers bridge.onsizechange", async () => {
184184
const receivedSizes: unknown[] = [];
185185
bridge.onsizechange = (params) => {
186186
receivedSizes.push(params);
187187
};
188188

189189
await app.connect(appTransport);
190-
await app.sendSizeChange({ width: 400, height: 600 });
190+
await app.sendSizeChanged({ width: 400, height: 600 });
191191

192192
expect(receivedSizes).toEqual([{ width: 400, height: 600 }]);
193193
});

src/app-bridge.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333

3434
import {
3535
type McpUiSandboxResourceReadyNotification,
36-
type McpUiSizeChangeNotification,
36+
type McpUiSizeChangedNotification,
3737
type McpUiToolInputNotification,
3838
type McpUiToolInputPartialNotification,
3939
type McpUiToolResultNotification,
@@ -57,7 +57,7 @@ import {
5757
McpUiResourceTeardownResultSchema,
5858
McpUiSandboxProxyReadyNotification,
5959
McpUiSandboxProxyReadyNotificationSchema,
60-
McpUiSizeChangeNotificationSchema,
60+
McpUiSizeChangedNotificationSchema,
6161
} from "./types";
6262
export * from "./types";
6363
export { PostMessageTransport } from "./message-transport";
@@ -270,7 +270,7 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
270270
* adjust the iframe container dimensions based on the Guest UI's content.
271271
*
272272
* Note: This is for Guest UI → Host communication. To notify the Guest UI of
273-
* host viewport changes, use {@link app.App.sendSizeChange}.
273+
* host viewport changes, use {@link app.App.sendSizeChanged}.
274274
*
275275
* @example
276276
* ```typescript
@@ -284,13 +284,13 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
284284
* };
285285
* ```
286286
*
287-
* @see {@link McpUiSizeChangeNotification} for the notification type
288-
* @see {@link app.App.sendSizeChange} for Host → Guest UI size notifications
287+
* @see {@link McpUiSizeChangedNotification} for the notification type
288+
* @see {@link app.App.sendSizeChanged} for Host → Guest UI size notifications
289289
*/
290290
set onsizechange(
291-
callback: (params: McpUiSizeChangeNotification["params"]) => void,
291+
callback: (params: McpUiSizeChangedNotification["params"]) => void,
292292
) {
293-
this.setNotificationHandler(McpUiSizeChangeNotificationSchema, (n) =>
293+
this.setNotificationHandler(McpUiSizeChangedNotificationSchema, (n) =>
294294
callback(n.params),
295295
);
296296
}

src/app.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
McpUiMessageResultSchema,
3232
McpUiOpenLinkRequest,
3333
McpUiOpenLinkResultSchema,
34-
McpUiSizeChangeNotification,
34+
McpUiSizeChangedNotification,
3535
McpUiToolInputNotification,
3636
McpUiToolInputNotificationSchema,
3737
McpUiToolInputPartialNotification,
@@ -707,18 +707,18 @@ export class App extends Protocol<Request, Notification, Result> {
707707
*
708708
* @example Manually notify host of size change
709709
* ```typescript
710-
* app.sendSizeChange({
710+
* app.sendSizeChanged({
711711
* width: 400,
712712
* height: 600
713713
* });
714714
* ```
715715
*
716716
* @returns Promise that resolves when the notification is sent
717717
*
718-
* @see {@link McpUiSizeChangeNotification} for notification structure
718+
* @see {@link McpUiSizeChangedNotification} for notification structure
719719
*/
720-
sendSizeChange(params: McpUiSizeChangeNotification["params"]) {
721-
return this.notification(<McpUiSizeChangeNotification>{
720+
sendSizeChanged(params: McpUiSizeChangedNotification["params"]) {
721+
return this.notification(<McpUiSizeChangedNotification>{
722722
method: "ui/notifications/size-changed",
723723
params,
724724
});
@@ -743,18 +743,18 @@ export class App extends Protocol<Request, Notification, Result> {
743743
* await app.connect(transport);
744744
*
745745
* // Later, enable auto-resize manually
746-
* const cleanup = app.setupSizeChangeNotifications();
746+
* const cleanup = app.setupSizeChangedNotifications();
747747
*
748748
* // Clean up when done
749749
* cleanup();
750750
* ```
751751
*/
752-
setupSizeChangeNotifications() {
752+
setupSizeChangedNotifications() {
753753
let scheduled = false;
754754
let lastWidth = 0;
755755
let lastHeight = 0;
756756

757-
const sendBodySizeChange = () => {
757+
const sendBodySizeChanged = () => {
758758
if (scheduled) {
759759
return;
760760
}
@@ -785,14 +785,14 @@ export class App extends Protocol<Request, Notification, Result> {
785785
if (width !== lastWidth || height !== lastHeight) {
786786
lastWidth = width;
787787
lastHeight = height;
788-
this.sendSizeChange({ width, height });
788+
this.sendSizeChanged({ width, height });
789789
}
790790
});
791791
};
792792

793-
sendBodySizeChange();
793+
sendBodySizeChanged();
794794

795-
const resizeObserver = new ResizeObserver(sendBodySizeChange);
795+
const resizeObserver = new ResizeObserver(sendBodySizeChanged);
796796
// Observe both html and body to catch all size changes
797797
resizeObserver.observe(document.documentElement);
798798
resizeObserver.observe(document.body);
@@ -808,7 +808,7 @@ export class App extends Protocol<Request, Notification, Result> {
808808
* 2. Sends `ui/initialize` request with app info and capabilities
809809
* 3. Receives host capabilities and context in response
810810
* 4. Sends `ui/notifications/initialized` notification
811-
* 5. Sets up auto-resize using {@link setupSizeChangeNotifications} if enabled (default)
811+
* 5. Sets up auto-resize using {@link setupSizeChangedNotifications} if enabled (default)
812812
*
813813
* If initialization fails, the connection is automatically closed and an error
814814
* is thrown.
@@ -869,7 +869,7 @@ export class App extends Protocol<Request, Notification, Result> {
869869
});
870870

871871
if (this.options?.autoResize) {
872-
this.setupSizeChangeNotifications();
872+
this.setupSizeChangedNotifications();
873873
}
874874
} catch (error) {
875875
// Disconnect if initialization fails.

src/react/useAutoResize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { App } from "../app";
4545
* }
4646
* ```
4747
*
48-
* @see {@link App.setupSizeChangeNotifications} for the underlying implementation
48+
* @see {@link App.setupSizeChangedNotifications} for the underlying implementation
4949
* @see {@link useApp} which enables auto-resize by default
5050
* @see {@link App} constructor for configuring `autoResize` option
5151
*/
@@ -58,6 +58,6 @@ export function useAutoResize(
5858
return;
5959
}
6060

61-
return app.setupSizeChangeNotifications();
61+
return app.setupSizeChangedNotifications();
6262
}, [app, elementRef]);
6363
}

src/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ type _VerifySandboxResourceReadyNotification = VerifySchemaMatches<
258258
* **Host → Guest UI**: Sent by the Host when the viewport size changes (e.g.,
259259
* window resize, orientation change). This allows the Guest UI to adjust its layout.
260260
*
261-
* @see {@link app.App.sendSizeChange} for the method to send this from Guest UI
262-
* @see {@link app.App.setupSizeChangeNotifications} for automatic size reporting
261+
* @see {@link app.App.sendSizeChanged} for the method to send this from Guest UI
262+
* @see {@link app.App.setupSizeChangedNotifications} for automatic size reporting
263263
*/
264-
export interface McpUiSizeChangeNotification {
264+
export interface McpUiSizeChangedNotification {
265265
method: "ui/notifications/size-changed";
266266
params: {
267267
/** New width in pixels */
@@ -272,10 +272,10 @@ export interface McpUiSizeChangeNotification {
272272
}
273273

274274
/**
275-
* Runtime validation schema for {@link McpUiSizeChangeNotification}.
275+
* Runtime validation schema for {@link McpUiSizeChangedNotification}.
276276
* @internal
277277
*/
278-
export const McpUiSizeChangeNotificationSchema = z.object({
278+
export const McpUiSizeChangedNotificationSchema = z.object({
279279
method: z.literal("ui/notifications/size-changed"),
280280
params: z.object({
281281
width: z.number().optional(),
@@ -285,8 +285,8 @@ export const McpUiSizeChangeNotificationSchema = z.object({
285285

286286
/** @internal - Compile-time verification that schema matches interface */
287287
type _VerifySizeChangeNotification = VerifySchemaMatches<
288-
typeof McpUiSizeChangeNotificationSchema,
289-
McpUiSizeChangeNotification
288+
typeof McpUiSizeChangedNotificationSchema,
289+
McpUiSizeChangedNotification
290290
>;
291291

292292
/**

0 commit comments

Comments
 (0)