@modelcontextprotocol/ext-apps 1.0.0 → 1.1.0

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/src/app.d.ts CHANGED
@@ -269,27 +269,20 @@ export declare class App extends Protocol<AppRequest, AppNotification, AppResult
269
269
  *
270
270
  * @example Progressive rendering of tool arguments
271
271
  * ```ts source="./app.examples.ts#App_ontoolinputpartial_progressiveRendering"
272
- * let toolInputs: Record<string, unknown> | null = null;
273
- * let toolInputsPartial: Record<string, unknown> | null = null;
272
+ * const codePreview = document.querySelector<HTMLPreElement>("#code-preview")!;
273
+ * const canvas = document.querySelector<HTMLCanvasElement>("#canvas")!;
274
274
  *
275
275
  * app.ontoolinputpartial = (params) => {
276
- * toolInputsPartial = params.arguments as Record<string, unknown>;
277
- * render();
276
+ * codePreview.textContent = (params.arguments?.code as string) ?? "";
277
+ * codePreview.style.display = "block";
278
+ * canvas.style.display = "none";
278
279
  * };
279
280
  *
280
281
  * app.ontoolinput = (params) => {
281
- * toolInputs = params.arguments as Record<string, unknown>;
282
- * toolInputsPartial = null;
283
- * render();
282
+ * codePreview.style.display = "none";
283
+ * canvas.style.display = "block";
284
+ * render(params.arguments?.code as string);
284
285
  * };
285
- *
286
- * function render() {
287
- * if (toolInputs) {
288
- * renderFinalUI(toolInputs);
289
- * } else {
290
- * renderLoadingUI(toolInputsPartial); // e.g., shimmer with partial preview
291
- * }
292
- * }
293
286
  * ```
294
287
  *
295
288
  * @see {@link setNotificationHandler `setNotificationHandler`} for the underlying method
@@ -376,8 +369,8 @@ export declare class App extends Protocol<AppRequest, AppNotification, AppResult
376
369
  *
377
370
  * @example Respond to theme changes
378
371
  * ```ts source="./app.examples.ts#App_onhostcontextchanged_respondToTheme"
379
- * app.onhostcontextchanged = (params) => {
380
- * if (params.theme === "dark") {
372
+ * app.onhostcontextchanged = (ctx) => {
373
+ * if (ctx.theme === "dark") {
381
374
  * document.body.classList.add("dark-theme");
382
375
  * } else {
383
376
  * document.body.classList.remove("dark-theme");
@@ -729,11 +722,12 @@ export declare class App extends Protocol<AppRequest, AppNotification, AppResult
729
722
  *
730
723
  * @example Toggle display mode
731
724
  * ```ts source="./app.examples.ts#App_requestDisplayMode_toggle"
725
+ * const container = document.getElementById("main")!;
732
726
  * const ctx = app.getHostContext();
733
- * if (ctx?.availableDisplayModes?.includes("fullscreen")) {
734
- * const target = ctx.displayMode === "fullscreen" ? "inline" : "fullscreen";
735
- * const result = await app.requestDisplayMode({ mode: target });
736
- * console.log("Now in:", result.mode);
727
+ * const newMode = ctx?.displayMode === "inline" ? "fullscreen" : "inline";
728
+ * if (ctx?.availableDisplayModes?.includes(newMode)) {
729
+ * const result = await app.requestDisplayMode({ mode: newMode });
730
+ * container.classList.toggle("fullscreen", result.mode === "fullscreen");
737
731
  * }
738
732
  * ```
739
733
  *