fix: change size-changed to be in correct tense (#83)

* fix: change size-changed to be in correct tense

* sdk changes
This commit is contained in:
Liad Yosef 2025-12-08 13:14:56 +02:00 • committed by GitHub
commit ba1a27e465
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,7 +31,7 @@ import {
McpUiMessageResultSchema,
McpUiOpenLinkRequest,
McpUiOpenLinkResultSchema,
McpUiSizeChangeNotification,
McpUiSizeChangedNotification,
McpUiToolInputNotification,
McpUiToolInputNotificationSchema,
McpUiToolInputPartialNotification,
@ -88,7 +88,7 @@ type AppOptions = ProtocolOptions & {
* Automatically report size changes to the host using ResizeObserver.
*
* When enabled, the App monitors `document.body` and `document.documentElement`
* for size changes and automatically sends `ui/notifications/size-change`
* for size changes and automatically sends `ui/notifications/size-changed`
* notifications to the host.
*
* @default true
@ -723,7 +723,7 @@ export class App extends Protocol<Request, Notification, Result> {
*
* @example Manually notify host of size change
* ```typescript
* app.sendSizeChange({
* app.sendSizeChanged({
* width: 400,
* height: 600
* });
@ -731,11 +731,11 @@ export class App extends Protocol<Request, Notification, Result> {
*
* @returns Promise that resolves when the notification is sent
*
* @see {@link McpUiSizeChangeNotification} for notification structure
* @see {@link McpUiSizeChangedNotification} for notification structure
*/
sendSizeChange(params: McpUiSizeChangeNotification["params"]) {
return this.notification(<McpUiSizeChangeNotification>{
method: "ui/notifications/size-change",
sendSizeChanged(params: McpUiSizeChangedNotification["params"]) {
return this.notification(<McpUiSizeChangedNotification>{
method: "ui/notifications/size-changed",
params,
});
}
@ -744,7 +744,7 @@ export class App extends Protocol<Request, Notification, Result> {
* Set up automatic size change notifications using ResizeObserver.
*
* Observes both `document.documentElement` and `document.body` for size changes
* and automatically sends `ui/notifications/size-change` notifications to the host.
* and automatically sends `ui/notifications/size-changed` notifications to the host.
* The notifications are debounced using requestAnimationFrame to avoid duplicates.
*
* Note: This method is automatically called by `connect()` if the `autoResize`
@ -759,18 +759,18 @@ export class App extends Protocol<Request, Notification, Result> {
* await app.connect(transport);
*
* // Later, enable auto-resize manually
* const cleanup = app.setupSizeChangeNotifications();
* const cleanup = app.setupSizeChangedNotifications();
*
* // Clean up when done
* cleanup();
* ```
*/
setupSizeChangeNotifications() {
setupSizeChangedNotifications() {
let scheduled = false;
let lastWidth = 0;
let lastHeight = 0;
const sendBodySizeChange = () => {
const sendBodySizeChanged = () => {
if (scheduled) {
return;
}
@ -801,14 +801,14 @@ export class App extends Protocol<Request, Notification, Result> {
if (width !== lastWidth || height !== lastHeight) {
lastWidth = width;
lastHeight = height;
this.sendSizeChange({ width, height });
this.sendSizeChanged({ width, height });
}
});
};
sendBodySizeChange();
sendBodySizeChanged();
const resizeObserver = new ResizeObserver(sendBodySizeChange);
const resizeObserver = new ResizeObserver(sendBodySizeChanged);
// Observe both html and body to catch all size changes
resizeObserver.observe(document.documentElement);
resizeObserver.observe(document.body);
@ -824,7 +824,7 @@ export class App extends Protocol<Request, Notification, Result> {
* 2. Sends `ui/initialize` request with app info and capabilities
* 3. Receives host capabilities and context in response
* 4. Sends `ui/notifications/initialized` notification
* 5. Sets up auto-resize using {@link setupSizeChangeNotifications} if enabled (default)
* 5. Sets up auto-resize using {@link setupSizeChangedNotifications} if enabled (default)
*
* If initialization fails, the connection is automatically closed and an error
* is thrown.
@ -885,7 +885,7 @@ export class App extends Protocol<Request, Notification, Result> {
});
if (this.options?.autoResize) {
this.setupSizeChangeNotifications();
this.setupSizeChangedNotifications();
}
} catch (error) {
// Disconnect if initialization fails.