Make height/width optional as well
This commit is contained in:
parent
87f6f3f27e
commit
4e01a6c200
4 changed files with 16 additions and 13 deletions
|
|
@ -464,9 +464,9 @@ interface HostContext {
|
||||||
/** Current and maximum dimensions available to the UI. */
|
/** Current and maximum dimensions available to the UI. */
|
||||||
viewport?: {
|
viewport?: {
|
||||||
/** Current viewport width in pixels. */
|
/** Current viewport width in pixels. */
|
||||||
width: number;
|
width?: number;
|
||||||
/** Current viewport height in pixels. */
|
/** Current viewport height in pixels. */
|
||||||
height: number;
|
height?: number;
|
||||||
/** Maximum available height in pixels (if constrained). */
|
/** Maximum available height in pixels (if constrained). */
|
||||||
maxHeight?: number;
|
maxHeight?: number;
|
||||||
/** Maximum available width in pixels (if constrained). */
|
/** Maximum available width in pixels (if constrained). */
|
||||||
|
|
@ -552,20 +552,20 @@ if (viewport) {
|
||||||
// Handle height
|
// Handle height
|
||||||
if ("height" in viewport) {
|
if ("height" in viewport) {
|
||||||
// Fixed height: fill the container
|
// Fixed height: fill the container
|
||||||
document.body.style.height = "100%";
|
document.documentElement.style.height = "100vh";
|
||||||
} else if (viewport.maxHeight) {
|
} else if (viewport.maxHeight) {
|
||||||
// Flexible with max: let content determine size, up to max
|
// Flexible with max: let content determine size, up to max
|
||||||
document.body.style.maxHeight = `${viewport.maxHeight}px`;
|
document.documentElement.style.maxHeight = `${viewport.maxHeight}px`;
|
||||||
}
|
}
|
||||||
// If neither, height is unbounded
|
// If neither, height is unbounded
|
||||||
|
|
||||||
// Handle width
|
// Handle width
|
||||||
if ("width" in viewport) {
|
if ("width" in viewport) {
|
||||||
// Fixed width: fill the container
|
// Fixed width: fill the container
|
||||||
document.body.style.width = "100%";
|
document.documentElement.style.width = "100vw";
|
||||||
} else if (viewport.maxWidth) {
|
} else if (viewport.maxWidth) {
|
||||||
// Flexible with max: let content determine size, up to max
|
// Flexible with max: let content determine size, up to max
|
||||||
document.body.style.maxWidth = `${viewport.maxWidth}px`;
|
document.documentElement.style.maxWidth = `${viewport.maxWidth}px`;
|
||||||
}
|
}
|
||||||
// If neither, width is unbounded
|
// If neither, width is unbounded
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
src/generated/schema.json
generated
3
src/generated/schema.json
generated
|
|
@ -649,7 +649,6 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["width", "height"],
|
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"locale": {
|
"locale": {
|
||||||
|
|
@ -1275,7 +1274,6 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["width", "height"],
|
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"locale": {
|
"locale": {
|
||||||
|
|
@ -2434,7 +2432,6 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["width", "height"],
|
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"locale": {
|
"locale": {
|
||||||
|
|
|
||||||
10
src/generated/schema.ts
generated
10
src/generated/schema.ts
generated
|
|
@ -566,9 +566,15 @@ export const McpUiHostContextSchema = z.looseObject({
|
||||||
viewport: z
|
viewport: z
|
||||||
.object({
|
.object({
|
||||||
/** @description Current viewport width in pixels. */
|
/** @description Current viewport width in pixels. */
|
||||||
width: z.number().describe("Current viewport width in pixels."),
|
width: z
|
||||||
|
.number()
|
||||||
|
.optional()
|
||||||
|
.describe("Current viewport width in pixels."),
|
||||||
/** @description Current viewport height in pixels. */
|
/** @description Current viewport height in pixels. */
|
||||||
height: z.number().describe("Current viewport height in pixels."),
|
height: z
|
||||||
|
.number()
|
||||||
|
.optional()
|
||||||
|
.describe("Current viewport height in pixels."),
|
||||||
/** @description Maximum available height in pixels (if constrained). */
|
/** @description Maximum available height in pixels (if constrained). */
|
||||||
maxHeight: z
|
maxHeight: z
|
||||||
.number()
|
.number()
|
||||||
|
|
|
||||||
|
|
@ -327,9 +327,9 @@ export interface McpUiHostContext {
|
||||||
/** @description Current and maximum dimensions available to the UI. */
|
/** @description Current and maximum dimensions available to the UI. */
|
||||||
viewport?: {
|
viewport?: {
|
||||||
/** @description Current viewport width in pixels. */
|
/** @description Current viewport width in pixels. */
|
||||||
width: number;
|
width?: number;
|
||||||
/** @description Current viewport height in pixels. */
|
/** @description Current viewport height in pixels. */
|
||||||
height: number;
|
height?: number;
|
||||||
/** @description Maximum available height in pixels (if constrained). */
|
/** @description Maximum available height in pixels (if constrained). */
|
||||||
maxHeight?: number;
|
maxHeight?: number;
|
||||||
/** @description Maximum available width in pixels (if constrained). */
|
/** @description Maximum available width in pixels (if constrained). */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue