@miragon/mcp-toolkit-ui 2.6.0 → 2.7.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/README.md +7 -1
- package/dist/app/builder/BuilderBanners.d.ts +7 -2
- package/dist/app/builder/BuilderBanners.d.ts.map +1 -1
- package/dist/app/builder/BuilderBanners.js +8 -3
- package/dist/app/builder/BuilderBanners.js.map +1 -1
- package/dist/app/builder/CanvasRow.d.ts.map +1 -1
- package/dist/app/builder/CanvasRow.js +12 -14
- package/dist/app/builder/CanvasRow.js.map +1 -1
- package/dist/app/builder/CatalogueSheet.d.ts.map +1 -1
- package/dist/app/builder/CatalogueSheet.js +6 -5
- package/dist/app/builder/CatalogueSheet.js.map +1 -1
- package/dist/app/builder/EmptyHint.d.ts +4 -0
- package/dist/app/builder/EmptyHint.d.ts.map +1 -1
- package/dist/app/builder/EmptyHint.js +6 -1
- package/dist/app/builder/EmptyHint.js.map +1 -1
- package/dist/app/builder/LayoutSurface.js +3 -3
- package/dist/app/builder/LayoutSurface.js.map +1 -1
- package/dist/app/builder/PipelineStrip.d.ts +3 -1
- package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
- package/dist/app/builder/PipelineStrip.js +11 -6
- package/dist/app/builder/PipelineStrip.js.map +1 -1
- package/dist/app/builder/SaveDialog.d.ts.map +1 -1
- package/dist/app/builder/SaveDialog.js +2 -2
- package/dist/app/builder/SaveDialog.js.map +1 -1
- package/dist/app/builder/Toolbar.d.ts +3 -1
- package/dist/app/builder/Toolbar.d.ts.map +1 -1
- package/dist/app/builder/Toolbar.js +9 -3
- package/dist/app/builder/Toolbar.js.map +1 -1
- package/dist/app/builder/Workspace.js +2 -2
- package/dist/app/builder/Workspace.js.map +1 -1
- package/dist/app/builder/builder-model.d.ts +3 -2
- package/dist/app/builder/builder-model.d.ts.map +1 -1
- package/dist/app/builder/builder-model.js +5 -4
- package/dist/app/builder/builder-model.js.map +1 -1
- package/dist/app/builder/labels.d.ts +13 -62
- package/dist/app/builder/labels.d.ts.map +1 -1
- package/dist/app/builder/labels.js +9 -58
- package/dist/app/builder/labels.js.map +1 -1
- package/dist/app/builder/status-chip.d.ts.map +1 -1
- package/dist/app/builder/status-chip.js +3 -2
- package/dist/app/builder/status-chip.js.map +1 -1
- package/dist/app/builder/use-builder-catalogue.d.ts +1 -0
- package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
- package/dist/app/builder/use-builder-catalogue.js +6 -0
- package/dist/app/builder/use-builder-catalogue.js.map +1 -1
- package/dist/app/builder/use-save-dashboard.d.ts +3 -1
- package/dist/app/builder/use-save-dashboard.d.ts.map +1 -1
- package/dist/app/builder/use-save-dashboard.js +3 -1
- package/dist/app/builder/use-save-dashboard.js.map +1 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js.map +1 -1
- package/dist/app/layout-builder.d.ts +7 -2
- package/dist/app/layout-builder.d.ts.map +1 -1
- package/dist/app/layout-builder.js +17 -5
- package/dist/app/layout-builder.js.map +1 -1
- package/dist/app/mcp-app-view-chrome.d.ts +94 -20
- package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
- package/dist/app/mcp-app-view-chrome.js +109 -40
- package/dist/app/mcp-app-view-chrome.js.map +1 -1
- package/dist/app/mcp-app-view-states.d.ts +15 -0
- package/dist/app/mcp-app-view-states.d.ts.map +1 -0
- package/dist/app/mcp-app-view-states.js +34 -0
- package/dist/app/mcp-app-view-states.js.map +1 -0
- package/dist/app/mcp-app-view.d.ts +40 -5
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +174 -128
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +2 -1
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +25 -3
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/use-view-lifecycle.d.ts +38 -0
- package/dist/app/use-view-lifecycle.d.ts.map +1 -0
- package/dist/app/use-view-lifecycle.js +79 -0
- package/dist/app/use-view-lifecycle.js.map +1 -0
- package/dist/app/view-lifecycle.d.ts +109 -0
- package/dist/app/view-lifecycle.d.ts.map +1 -0
- package/dist/app/view-lifecycle.js +120 -0
- package/dist/app/view-lifecycle.js.map +1 -0
- package/dist/app/widget-props-sheet.d.ts +3 -9
- package/dist/app/widget-props-sheet.d.ts.map +1 -1
- package/dist/app/widget-props-sheet.js +6 -13
- package/dist/app/widget-props-sheet.js.map +1 -1
- package/dist/app/widget-renderer.d.ts +41 -1
- package/dist/app/widget-renderer.d.ts.map +1 -1
- package/dist/app/widget-renderer.js +82 -31
- package/dist/app/widget-renderer.js.map +1 -1
- package/dist/components/DrillButton.d.ts.map +1 -1
- package/dist/components/DrillButton.js +2 -1
- package/dist/components/DrillButton.js.map +1 -1
- package/dist/components/EmptyState.d.ts +33 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +17 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/ErrorState.d.ts +50 -0
- package/dist/components/ErrorState.d.ts.map +1 -0
- package/dist/components/ErrorState.js +60 -0
- package/dist/components/ErrorState.js.map +1 -0
- package/dist/components/FilterBar.d.ts +1 -1
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +7 -4
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/GroupCard.d.ts.map +1 -1
- package/dist/components/GroupCard.js +2 -1
- package/dist/components/GroupCard.js.map +1 -1
- package/dist/components/KpiGrid.d.ts +10 -3
- package/dist/components/KpiGrid.d.ts.map +1 -1
- package/dist/components/KpiGrid.js +31 -9
- package/dist/components/KpiGrid.js.map +1 -1
- package/dist/components/ListFooter.d.ts +3 -2
- package/dist/components/ListFooter.d.ts.map +1 -1
- package/dist/components/ListFooter.js +14 -4
- package/dist/components/ListFooter.js.map +1 -1
- package/dist/components/Pills.d.ts +10 -6
- package/dist/components/Pills.d.ts.map +1 -1
- package/dist/components/Pills.js +12 -6
- package/dist/components/Pills.js.map +1 -1
- package/dist/components/Toast.d.ts +37 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +91 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/WidgetHeader.js +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +23 -1
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +21 -7
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/hooks/use-view-data.d.ts +6 -0
- package/dist/hooks/use-view-data.d.ts.map +1 -1
- package/dist/hooks/use-view-data.js +6 -1
- package/dist/hooks/use-view-data.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/focus-ring.d.ts +18 -0
- package/dist/lib/focus-ring.d.ts.map +1 -0
- package/dist/lib/focus-ring.js +18 -0
- package/dist/lib/focus-ring.js.map +1 -0
- package/dist/lib/icon-stroke.d.ts +12 -0
- package/dist/lib/icon-stroke.d.ts.map +1 -0
- package/dist/lib/icon-stroke.js +12 -0
- package/dist/lib/icon-stroke.js.map +1 -0
- package/dist/lib/toast-model.d.ts +46 -0
- package/dist/lib/toast-model.d.ts.map +1 -0
- package/dist/lib/toast-model.js +36 -0
- package/dist/lib/toast-model.js.map +1 -0
- package/dist/lib/tone-utils.d.ts +43 -9
- package/dist/lib/tone-utils.d.ts.map +1 -1
- package/dist/lib/tone-utils.js +36 -7
- package/dist/lib/tone-utils.js.map +1 -1
- package/dist/locale/index.d.ts +3 -1
- package/dist/locale/index.d.ts.map +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/locale-provider.d.ts +42 -1
- package/dist/locale/locale-provider.d.ts.map +1 -1
- package/dist/locale/locale-provider.js +44 -3
- package/dist/locale/locale-provider.js.map +1 -1
- package/dist/locale/message-types.d.ts +223 -0
- package/dist/locale/message-types.d.ts.map +1 -0
- package/dist/locale/message-types.js +7 -0
- package/dist/locale/message-types.js.map +1 -0
- package/dist/locale/messages-de.d.ts +9 -0
- package/dist/locale/messages-de.d.ts.map +1 -0
- package/dist/locale/messages-de.js +151 -0
- package/dist/locale/messages-de.js.map +1 -0
- package/dist/locale/messages-en.d.ts +8 -0
- package/dist/locale/messages-en.d.ts.map +1 -0
- package/dist/locale/messages-en.js +150 -0
- package/dist/locale/messages-en.js.map +1 -0
- package/dist/locale/toolkit-messages.d.ts +39 -0
- package/dist/locale/toolkit-messages.d.ts.map +1 -0
- package/dist/locale/toolkit-messages.js +50 -0
- package/dist/locale/toolkit-messages.js.map +1 -0
- package/dist/primitives/alert.d.ts.map +1 -1
- package/dist/primitives/alert.js +4 -2
- package/dist/primitives/alert.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/badge.js +14 -6
- package/dist/primitives/badge.js.map +1 -1
- package/dist/primitives/button.d.ts.map +1 -1
- package/dist/primitives/button.js +12 -8
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/card.js +4 -4
- package/dist/primitives/card.js.map +1 -1
- package/dist/primitives/dialog.d.ts +7 -3
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +14 -7
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +4 -1
- package/dist/primitives/input.js.map +1 -1
- package/dist/primitives/scroll-area.js +1 -1
- package/dist/primitives/scroll-area.js.map +1 -1
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +5 -2
- package/dist/primitives/select.js.map +1 -1
- package/dist/primitives/sheet.d.ts +3 -1
- package/dist/primitives/sheet.d.ts.map +1 -1
- package/dist/primitives/sheet.js +12 -6
- package/dist/primitives/sheet.js.map +1 -1
- package/dist/primitives/skeleton.js +1 -1
- package/dist/primitives/skeleton.js.map +1 -1
- package/dist/primitives/switch.d.ts.map +1 -1
- package/dist/primitives/switch.js +2 -1
- package/dist/primitives/switch.js.map +1 -1
- package/dist/primitives/tabs.d.ts.map +1 -1
- package/dist/primitives/tabs.js +5 -3
- package/dist/primitives/tabs.js.map +1 -1
- package/dist/render-cases.d.ts.map +1 -1
- package/dist/render-cases.js +20 -2
- package/dist/render-cases.js.map +1 -1
- package/dist/render-scan.d.ts +25 -0
- package/dist/render-scan.d.ts.map +1 -0
- package/dist/render-scan.js +66 -0
- package/dist/render-scan.js.map +1 -0
- package/dist/theme/cd-tokens.d.ts +66 -0
- package/dist/theme/cd-tokens.d.ts.map +1 -0
- package/dist/theme/cd-tokens.js +64 -0
- package/dist/theme/cd-tokens.js.map +1 -0
- package/dist/theme/create-theme.d.ts +196 -39
- package/dist/theme/create-theme.d.ts.map +1 -1
- package/dist/theme/create-theme.js +189 -13
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/fonts.d.ts +38 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +56 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/host-fonts.d.ts +39 -0
- package/dist/theme/host-fonts.d.ts.map +1 -0
- package/dist/theme/host-fonts.js +44 -0
- package/dist/theme/host-fonts.js.map +1 -0
- package/dist/theme/index.d.ts +8 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +5 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/portal-container.d.ts +16 -0
- package/dist/theme/portal-container.d.ts.map +1 -0
- package/dist/theme/portal-container.js +19 -0
- package/dist/theme/portal-container.js.map +1 -0
- package/dist/theme/presets.d.ts +24 -9
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +44 -11
- package/dist/theme/presets.js.map +1 -1
- package/dist/theme/theme-provider.d.ts +27 -9
- package/dist/theme/theme-provider.d.ts.map +1 -1
- package/dist/theme/theme-provider.js +42 -20
- package/dist/theme/theme-provider.js.map +1 -1
- package/package.json +9 -4
- package/src/app/builder/BuilderBanners.tsx +26 -13
- package/src/app/builder/CanvasRow.tsx +22 -21
- package/src/app/builder/CatalogueSheet.tsx +16 -14
- package/src/app/builder/EmptyHint.tsx +16 -11
- package/src/app/builder/LayoutSurface.tsx +7 -7
- package/src/app/builder/PipelineStrip.tsx +26 -17
- package/src/app/builder/SaveDialog.tsx +11 -12
- package/src/app/builder/Toolbar.tsx +19 -7
- package/src/app/builder/Workspace.tsx +5 -3
- package/src/app/builder/builder-feedback.test.tsx +75 -0
- package/src/app/builder/builder-model.test.ts +5 -0
- package/src/app/builder/builder-model.ts +5 -4
- package/src/app/builder/labels.ts +15 -121
- package/src/app/builder/status-chip.tsx +8 -4
- package/src/app/builder/use-builder-catalogue.ts +6 -0
- package/src/app/builder/use-save-dashboard.ts +5 -0
- package/src/app/index.ts +8 -1
- package/src/app/layout-builder.tsx +23 -3
- package/src/app/mcp-app-view-chrome.test.tsx +347 -14
- package/src/app/mcp-app-view-chrome.tsx +278 -100
- package/src/app/mcp-app-view-states.tsx +100 -0
- package/src/app/mcp-app-view.test.tsx +258 -0
- package/src/app/mcp-app-view.tsx +292 -185
- package/src/app/mcp-toolkit-app.tsx +31 -7
- package/src/app/use-view-lifecycle.ts +116 -0
- package/src/app/view-lifecycle.test.ts +227 -0
- package/src/app/view-lifecycle.ts +174 -0
- package/src/app/widget-props-sheet.tsx +13 -26
- package/src/app/widget-renderer.render.test.tsx +131 -0
- package/src/app/widget-renderer.tsx +136 -38
- package/src/components/DrillButton.tsx +2 -1
- package/src/components/EmptyState.tsx +81 -0
- package/src/components/ErrorState.tsx +182 -0
- package/src/components/FilterBar.tsx +9 -6
- package/src/components/GroupCard.tsx +3 -2
- package/src/components/KpiGrid.tsx +75 -44
- package/src/components/ListFooter.tsx +17 -6
- package/src/components/Pills.tsx +20 -11
- package/src/components/Toast.tsx +188 -0
- package/src/components/WidgetHeader.tsx +1 -1
- package/src/components/feedback-states.test.tsx +225 -0
- package/src/components/tone-figures.test.tsx +54 -0
- package/src/fonts.css +19 -0
- package/src/globals.css +9 -165
- package/src/hooks/use-tool-result-recovery.test.ts +25 -1
- package/src/hooks/use-tool-result-recovery.ts +34 -6
- package/src/hooks/use-view-data.test.tsx +60 -0
- package/src/hooks/use-view-data.ts +12 -1
- package/src/i18n-coverage.test.tsx +323 -0
- package/src/index.ts +57 -5
- package/src/lib/focus-ring.ts +20 -0
- package/src/lib/icon-stroke.test.ts +59 -0
- package/src/lib/icon-stroke.ts +13 -0
- package/src/lib/toast-model.test.ts +68 -0
- package/src/lib/toast-model.ts +63 -0
- package/src/lib/tone-utils.test.ts +47 -14
- package/src/lib/tone-utils.ts +61 -13
- package/src/locale/index.ts +13 -1
- package/src/locale/locale-provider.test.tsx +87 -0
- package/src/locale/locale-provider.tsx +90 -3
- package/src/locale/message-types.ts +221 -0
- package/src/locale/messages-de.ts +159 -0
- package/src/locale/messages-en.ts +157 -0
- package/src/locale/toolkit-messages.test.ts +216 -0
- package/src/locale/toolkit-messages.ts +82 -0
- package/src/no-hardcoded-copy.test.ts +432 -0
- package/src/primitives/alert.tsx +4 -2
- package/src/primitives/badge.tsx +14 -7
- package/src/primitives/button.tsx +13 -8
- package/src/primitives/card.tsx +4 -4
- package/src/primitives/dialog.tsx +32 -7
- package/src/primitives/input.tsx +5 -3
- package/src/primitives/scroll-area.tsx +1 -1
- package/src/primitives/select.tsx +6 -3
- package/src/primitives/sheet.tsx +26 -6
- package/src/primitives/skeleton.tsx +1 -1
- package/src/primitives/switch.tsx +4 -2
- package/src/primitives/tabs.tsx +9 -6
- package/src/render-cases.tsx +45 -1
- package/src/render-scan.ts +75 -0
- package/src/theme/cd-tokens.generated.css +48 -0
- package/src/theme/cd-tokens.test.ts +107 -0
- package/src/theme/cd-tokens.ts +67 -0
- package/src/theme/create-theme.test.ts +243 -5
- package/src/theme/create-theme.ts +313 -41
- package/src/theme/fonts.test.ts +85 -0
- package/src/theme/fonts.ts +72 -0
- package/src/theme/host-fonts.test.ts +135 -0
- package/src/theme/host-fonts.ts +52 -0
- package/src/theme/index.ts +15 -1
- package/src/theme/portal-container.ts +20 -0
- package/src/theme/presets.ts +44 -11
- package/src/theme/theme-css.test.ts +568 -0
- package/src/theme/theme-provider.test.tsx +82 -0
- package/src/theme/theme-provider.tsx +60 -24
- package/src/theme.css +314 -0
- package/ui-catalog.json +344 -17
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type DescribeStep, type McpAppViewLabels, type ViewTitleLevel, type ViewTitleMode } from "./mcp-app-view-chrome.js";
|
|
3
|
+
import { type DescribeViewError } from "./mcp-app-view-states.js";
|
|
4
|
+
import type { LayoutBuilderLabels } from "./layout-builder.js";
|
|
2
5
|
import type { WidgetComponent } from "./widget-renderer.js";
|
|
3
|
-
export type { McpAppViewLabels } from "./mcp-app-view-chrome.js";
|
|
6
|
+
export type { McpAppViewLabels, ViewTitleLevel, ViewTitleMode } from "./mcp-app-view-chrome.js";
|
|
7
|
+
export type { DescribeStep } from "./mcp-app-view-chrome.js";
|
|
8
|
+
export type { DescribeViewError } from "./mcp-app-view-states.js";
|
|
4
9
|
export interface McpAppViewProps {
|
|
5
10
|
/**
|
|
6
11
|
* Map of widget ID to React component. The consumer aggregates this from
|
|
@@ -28,10 +33,40 @@ export interface McpAppViewProps {
|
|
|
28
33
|
*/
|
|
29
34
|
builderEnabled?: boolean;
|
|
30
35
|
/**
|
|
31
|
-
* Override
|
|
32
|
-
* Defaults to
|
|
36
|
+
* Override chrome strings (loading, error, refresh, fullscreen, edit, …).
|
|
37
|
+
* Defaults to the active locale's toolkit catalog: the nearest
|
|
38
|
+
* `LocaleProvider`, else the host's locale (`en`/`de`, English otherwise).
|
|
33
39
|
*/
|
|
34
40
|
labels?: McpAppViewLabels;
|
|
41
|
+
/** Override strings of the embedded view builder (defaults: the locale's catalog). */
|
|
42
|
+
builderLabels?: LayoutBuilderLabels;
|
|
43
|
+
/**
|
|
44
|
+
* How the toolbar shows the view title, so a view carries ONE title:
|
|
45
|
+
* `"show"` (default) renders it as a heading, `"hide"` leaves the title to
|
|
46
|
+
* the widget's own header, `"slot"` renders {@link McpAppViewProps.renderTitle}.
|
|
47
|
+
*/
|
|
48
|
+
titleMode?: ViewTitleMode;
|
|
49
|
+
/** Heading level of the toolbar title in `"show"` mode. Default `2`. */
|
|
50
|
+
titleLevel?: ViewTitleLevel;
|
|
51
|
+
/** Renders the toolbar title in `"slot"` mode; receives the view's title. */
|
|
52
|
+
renderTitle?: (title: string | undefined) => ReactNode;
|
|
53
|
+
/** Delay before the loading placeholder adds its "taking longer" hint. Default 8000 ms. */
|
|
54
|
+
slowHintAfterMs?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Map a raw rendering error (the tool's `isError` text) onto human text.
|
|
57
|
+
* The raw reason always stays available under "Details".
|
|
58
|
+
*/
|
|
59
|
+
describeError?: DescribeViewError;
|
|
60
|
+
/** Human title of a pipeline step in the failed-steps alert (default: the step id). */
|
|
61
|
+
describeStep?: DescribeStep;
|
|
35
62
|
}
|
|
36
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The toolkit's MCP App view: lifecycle placeholder (waiting / error /
|
|
65
|
+
* cancelled), toolbar, failed-steps alert and the rendered layout (or the
|
|
66
|
+
* builder). Mounts a `ToastProvider` and binds the toolkit's own strings to
|
|
67
|
+
* the host's locale unless a `LocaleProvider` sets one, so the chrome follows
|
|
68
|
+
* the host language; `useLocale()` in consumer widgets is unaffected. Lucide
|
|
69
|
+
* icons draw at the CI stroke (2.5) throughout, the toast stack included.
|
|
70
|
+
*/
|
|
71
|
+
export declare function McpAppView(props: McpAppViewProps): import("react").JSX.Element;
|
|
37
72
|
//# sourceMappingURL=mcp-app-view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-view.d.ts","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-app-view.d.ts","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAatE,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAG9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC/F,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,sFAAsF;IACtF,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,wEAAwE;IACxE,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,6EAA6E;IAC7E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,SAAS,CAAA;IACtD,2FAA2F;IAC3F,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,uFAAuF;IACvF,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,+BAYhD"}
|
package/dist/app/mcp-app-view.js
CHANGED
|
@@ -1,159 +1,205 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback } from "react";
|
|
2
|
+
import { useState, useCallback, useMemo } from "react";
|
|
3
|
+
import { LucideProvider } from "lucide-react";
|
|
3
4
|
import { ToolCancelledError, useDisplayMode, useHostContext, useToolContext } from "mcp-use/react";
|
|
5
|
+
import { ToastProvider, useToast } from "../components/Toast.js";
|
|
6
|
+
import { ToolkitLocaleFallback, useToolkitMessages } from "../locale/locale-provider.js";
|
|
4
7
|
import { AppQueryProvider, queryClient } from "../providers/query-provider.js";
|
|
5
|
-
import { useToolResultRecovery } from "../hooks/use-tool-result-recovery.js";
|
|
6
|
-
import {
|
|
8
|
+
import { resolveRecoveryToolName, useToolResultRecovery, } from "../hooks/use-tool-result-recovery.js";
|
|
9
|
+
import { ICON_STROKE } from "../lib/icon-stroke.js";
|
|
7
10
|
import { useHostBridge } from "./host-bridge.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
import { applyBuilderCommit, fullscreenAvailable, isCompleteViewData, StepErrors, ViewBody, ViewToolbar, } from "./mcp-app-view-chrome.js";
|
|
12
|
+
import { ViewPlaceholder } from "./mcp-app-view-states.js";
|
|
13
|
+
import { useRetryFocus, useViewLifecycle } from "./use-view-lifecycle.js";
|
|
14
|
+
import { DEFAULT_SLOW_HINT_MS, decodeViewResult } from "./view-lifecycle.js";
|
|
15
|
+
/**
|
|
16
|
+
* The toolkit's MCP App view: lifecycle placeholder (waiting / error /
|
|
17
|
+
* cancelled), toolbar, failed-steps alert and the rendered layout (or the
|
|
18
|
+
* builder). Mounts a `ToastProvider` and binds the toolkit's own strings to
|
|
19
|
+
* the host's locale unless a `LocaleProvider` sets one, so the chrome follows
|
|
20
|
+
* the host language; `useLocale()` in consumer widgets is unaffected. Lucide
|
|
21
|
+
* icons draw at the CI stroke (2.5) throughout, the toast stack included.
|
|
22
|
+
*/
|
|
23
|
+
export function McpAppView(props) {
|
|
24
|
+
const { locale } = useHostContext();
|
|
25
|
+
return (_jsx(ToolkitLocaleFallback, { locale: locale, children: _jsx(LucideProvider, { strokeWidth: ICON_STROKE, children: _jsx(ToastProvider, { children: _jsx(McpAppViewShell, { ...props }) }) }) }));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Host-delivered payload → local `viewData`, recovered payloads included.
|
|
29
|
+
* Render-phase setState (not an effect) so the React Compiler doesn't flag a
|
|
30
|
+
* cascading render.
|
|
31
|
+
*/
|
|
32
|
+
function useHostViewData(initialViewData, isPending, recovered) {
|
|
27
33
|
const [viewData, setViewData] = useState(null);
|
|
28
|
-
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
29
|
-
// In-iframe build mode is purely a UI state — the LLM never sees the
|
|
30
|
-
// catalogue, the user toggles into build by clicking the toolbar button.
|
|
31
|
-
const [buildMode, setBuildMode] = useState(false);
|
|
32
|
-
// Sync host-provided initialViewData → local viewData via render-phase
|
|
33
|
-
// setState (rather than an effect) so the React Compiler doesn't flag a
|
|
34
|
-
// cascading render. The guard against transient empty toolOutput stays:
|
|
35
|
-
// widgetProps may briefly drop `context`/`layout` when displayMode toggles,
|
|
36
|
-
// and we don't want that to clobber a valid viewData.
|
|
37
|
-
//
|
|
38
34
|
// `prev` MUST start as `null`, not `initialViewData`: hosts that expose the
|
|
39
35
|
// complete tool output before the app's first render (e.g. window.openai
|
|
40
36
|
// globals injected ahead of script execution) would otherwise never trip the
|
|
41
|
-
// identity check —
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
// identity check — the sync never runs and the app idles on the skeleton.
|
|
38
|
+
// The completeness guard stays: widgetProps may briefly drop
|
|
39
|
+
// `context`/`layout` when displayMode toggles.
|
|
40
|
+
const [prevInitial, setPrevInitial] = useState(null);
|
|
41
|
+
if (initialViewData !== prevInitial) {
|
|
42
|
+
setPrevInitial(initialViewData);
|
|
43
|
+
if (!isPending && isCompleteViewData(initialViewData))
|
|
47
44
|
setViewData(initialViewData);
|
|
48
|
-
}
|
|
49
45
|
}
|
|
50
|
-
// Hosts that strip `structuredContent` from the tool-result notification
|
|
51
|
-
// (claude.ai / Claude Desktop) never latch a result under mcp-use 2.x — the
|
|
52
|
-
// `useToolContext` latch ignores content-only results, so `isPending` stays
|
|
53
|
-
// true forever. The recovery therefore also arms itself on a grace timer
|
|
54
|
-
// once the originating tool is known, re-executes it via `callTool`
|
|
55
|
-
// (responses carry `structuredContent` intact), and fills the gap.
|
|
56
|
-
// Conforming hosts deliver a valid payload up front, so it never fires
|
|
57
|
-
// there.
|
|
58
|
-
const recovery = useToolResultRecovery({
|
|
59
|
-
resultReady: !isPending,
|
|
60
|
-
cancelled: isCancelled,
|
|
61
|
-
props: initialViewData,
|
|
62
|
-
isValid: isCompleteViewData,
|
|
63
|
-
toolInput,
|
|
64
|
-
hostContext,
|
|
65
|
-
callTool,
|
|
66
|
-
});
|
|
67
46
|
const [prevRecovered, setPrevRecovered] = useState(null);
|
|
68
|
-
if (
|
|
69
|
-
setPrevRecovered(
|
|
47
|
+
if (recovered !== prevRecovered) {
|
|
48
|
+
setPrevRecovered(recovered);
|
|
70
49
|
// The host-delivered payload always wins; recovery only fills the gap.
|
|
71
|
-
if (
|
|
72
|
-
setViewData(
|
|
50
|
+
if (recovered && !viewData)
|
|
51
|
+
setViewData(recovered);
|
|
73
52
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, [displayMode, requestDisplayMode]);
|
|
86
|
-
// Stable callTool callback (avoids a new object reference on every render)
|
|
87
|
-
const callToolFn = useCallback(async (name, args) => {
|
|
88
|
-
return callTool(name, args);
|
|
89
|
-
}, [callTool]);
|
|
53
|
+
return [viewData, setViewData];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Refresh via the refresh tool. A failure keeps the data and says so in a
|
|
57
|
+
* toast in catalog words only; the raw reason goes to the console, never to
|
|
58
|
+
* the user.
|
|
59
|
+
*/
|
|
60
|
+
function useViewRefresh(options) {
|
|
61
|
+
const { viewData, setViewData, callTool, refreshToolName, labels } = options;
|
|
62
|
+
const toast = useToast();
|
|
63
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
90
64
|
const refreshView = useCallback(async () => {
|
|
91
65
|
if (!viewData?._refreshParams)
|
|
92
66
|
return;
|
|
93
67
|
setIsRefreshing(true);
|
|
68
|
+
let failure = null;
|
|
94
69
|
try {
|
|
95
70
|
const result = await callTool(refreshToolName, viewData._refreshParams);
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
setViewData(
|
|
101
|
-
|
|
102
|
-
|
|
71
|
+
// One decoding convention with `useToolQuery` (structured-first), with a
|
|
72
|
+
// typed outcome: an unusable payload is a failure, never exception text.
|
|
73
|
+
const outcome = decodeViewResult(result, isCompleteViewData);
|
|
74
|
+
if (outcome.ok)
|
|
75
|
+
setViewData(outcome.data);
|
|
76
|
+
else
|
|
77
|
+
failure = outcome.reason ?? "the refresh tool returned no view";
|
|
78
|
+
// The call went through, so self-fetching widgets refresh as well;
|
|
79
|
+
// a tool error refreshes nothing.
|
|
80
|
+
if (outcome.ok || !outcome.isError)
|
|
81
|
+
void queryClient.invalidateQueries();
|
|
103
82
|
}
|
|
104
83
|
catch (e) {
|
|
105
|
-
|
|
84
|
+
failure = e;
|
|
106
85
|
}
|
|
107
86
|
finally {
|
|
108
87
|
setIsRefreshing(false);
|
|
109
88
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
89
|
+
if (failure === null)
|
|
90
|
+
return;
|
|
91
|
+
console.warn("[mcp-toolkit] refresh failed:", failure);
|
|
92
|
+
toast.show({
|
|
93
|
+
tone: "danger",
|
|
94
|
+
title: labels.refreshFailed,
|
|
95
|
+
description: labels.refreshFailedHint,
|
|
96
|
+
});
|
|
97
|
+
}, [callTool, labels, refreshToolName, setViewData, toast, viewData]);
|
|
98
|
+
return { isRefreshing, refreshView };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The fullscreen toggle, gated on the host's offer. A rejected request shows
|
|
102
|
+
* a toast in catalog words; the raw reason goes to the console.
|
|
103
|
+
*/
|
|
104
|
+
function useFullscreenToggle(labels) {
|
|
105
|
+
const { displayMode, availableDisplayModes, requestDisplayMode } = useDisplayMode();
|
|
106
|
+
const toast = useToast();
|
|
107
|
+
const toggle = useCallback(async () => {
|
|
108
|
+
const mode = displayMode === "fullscreen" ? "inline" : "fullscreen";
|
|
109
|
+
try {
|
|
110
|
+
// Advisory since 2.x: `displayMode` updates when the host applies it.
|
|
111
|
+
await requestDisplayMode({ mode });
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
console.warn("[mcp-toolkit] display-mode request failed:", e);
|
|
115
|
+
toast.show({
|
|
116
|
+
tone: "danger",
|
|
117
|
+
title: labels.fullscreenFailed,
|
|
118
|
+
description: labels.fullscreenFailedHint,
|
|
119
|
+
});
|
|
130
120
|
}
|
|
121
|
+
}, [displayMode, labels, requestDisplayMode, toast]);
|
|
122
|
+
return {
|
|
123
|
+
isFullscreen: displayMode === "fullscreen",
|
|
124
|
+
canFullscreen: fullscreenAvailable(displayMode, availableDisplayModes),
|
|
125
|
+
toggle,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function McpAppViewShell({ widgets, refreshToolName = "refresh-view", builderEnabled, labels, builderLabels, titleMode = "show", titleLevel = 2, renderTitle, slowHintAfterMs = DEFAULT_SLOW_HINT_MS, describeError, describeStep, }) {
|
|
129
|
+
const messages = useToolkitMessages();
|
|
130
|
+
const L = useMemo(() => ({ ...messages.view, ...labels }), [messages.view, labels]);
|
|
131
|
+
// The mcp-use 2.x view channels (all need the `bootstrapView` mount
|
|
132
|
+
// `mountMcpToolkitApp` provides); tools go through the HostBridge.
|
|
133
|
+
const tool = useToolContext();
|
|
134
|
+
const { safeArea, hostContext } = useHostContext();
|
|
135
|
+
const bridge = useHostBridge();
|
|
136
|
+
const callTool = useCallback((name, args) => bridge.callTool(name, args), [bridge]);
|
|
137
|
+
// The widget-facing shape (`args: object`, so generated input interfaces
|
|
138
|
+
// without an index signature pass straight through).
|
|
139
|
+
const callToolFn = useCallback((name, args) => bridge.callTool(name, args), [bridge]);
|
|
140
|
+
const isPending = tool.status === "pending";
|
|
141
|
+
// Since mcp-use 2.7.1 a host cancellation latches as `status: "error"`.
|
|
142
|
+
const isCancelled = tool.status === "error" && tool.error instanceof ToolCancelledError;
|
|
143
|
+
const isCallError = tool.status === "error" && !isCancelled;
|
|
144
|
+
const initialViewData = tool.status === "ready" ? tool.toolOutput : undefined;
|
|
145
|
+
// Hosts that strip `structuredContent` (claude.ai) never latch a result under
|
|
146
|
+
// mcp-use 2.x; the recovery re-executes the call once to fill the gap. It
|
|
147
|
+
// never fires on a cancelled or failed call (#176): those render their state.
|
|
148
|
+
const recovery = useToolResultRecovery({
|
|
149
|
+
resultReady: !isPending,
|
|
150
|
+
cancelled: isCancelled,
|
|
151
|
+
errored: isCallError,
|
|
152
|
+
props: initialViewData,
|
|
153
|
+
isValid: isCompleteViewData,
|
|
154
|
+
toolInput: tool.toolInput,
|
|
155
|
+
hostContext,
|
|
156
|
+
callTool,
|
|
157
|
+
});
|
|
158
|
+
const [viewData, setViewData] = useHostViewData(initialViewData, isPending, recovery.data);
|
|
159
|
+
const { lifecycle, retry: retryCall } = useViewLifecycle({
|
|
160
|
+
hasViewData: viewData !== null,
|
|
161
|
+
callStatus: tool.status,
|
|
162
|
+
cancelled: isCancelled,
|
|
163
|
+
callError: isCallError ? tool.error : undefined,
|
|
164
|
+
recoveryFailed: recovery.failed,
|
|
165
|
+
toolName: resolveRecoveryToolName(hostContext),
|
|
166
|
+
toolInput: tool.toolInput,
|
|
167
|
+
callTool,
|
|
168
|
+
isValid: isCompleteViewData,
|
|
169
|
+
onResult: setViewData,
|
|
170
|
+
slowHintAfterMs,
|
|
171
|
+
});
|
|
172
|
+
const { frameRef, retry } = useRetryFocus(lifecycle.phase, retryCall);
|
|
173
|
+
const { isRefreshing, refreshView } = useViewRefresh({
|
|
174
|
+
viewData,
|
|
175
|
+
setViewData,
|
|
176
|
+
callTool,
|
|
177
|
+
refreshToolName,
|
|
178
|
+
labels: L,
|
|
179
|
+
});
|
|
180
|
+
const fullscreen = useFullscreenToggle(L);
|
|
181
|
+
// In-iframe build mode is purely a UI state — the LLM never sees the catalogue.
|
|
182
|
+
const [buildMode, setBuildMode] = useState(false);
|
|
183
|
+
const exitBuildMode = useCallback((commit) => {
|
|
184
|
+
if (commit)
|
|
185
|
+
setViewData((prev) => (prev ? applyBuilderCommit(prev, commit) : prev));
|
|
131
186
|
setBuildMode(false);
|
|
132
|
-
}, []);
|
|
133
|
-
// `isPending` must not gate the render: on hosts
|
|
134
|
-
//
|
|
135
|
-
//
|
|
187
|
+
}, [setViewData]);
|
|
188
|
+
// `isPending` must not gate the render: on stripping hosts the latch stays
|
|
189
|
+
// "pending" forever, and recovered viewData still has to replace it. The
|
|
190
|
+
// frame is the stable focus target of a retry (`useRetryFocus`).
|
|
136
191
|
if (!viewData) {
|
|
137
|
-
return _jsx(ViewPlaceholder, {
|
|
192
|
+
return (_jsx("div", { ref: frameRef, tabIndex: -1, "data-slot": "mcp-app-view", className: "outline-hidden", children: _jsx(ViewPlaceholder, { lifecycle: lifecycle, labels: L, onRetry: retry, describeError: describeError }) }));
|
|
138
193
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// `bootstrapView`'s auto-resize, so we let content dictate height and
|
|
150
|
-
// avoid setting overflowY (which would clip our own content inside a
|
|
151
|
-
// host that's already auto-sized to us).
|
|
152
|
-
...(isFullscreen ? { minHeight: "100vh", overflowY: "auto" } : null),
|
|
153
|
-
paddingTop: safeArea.top,
|
|
154
|
-
paddingRight: safeArea.right,
|
|
155
|
-
paddingBottom: safeArea.bottom,
|
|
156
|
-
paddingLeft: safeArea.left,
|
|
157
|
-
}, children: [_jsx(ViewToolbar, { hidden: buildMode, viewData: viewData, builderAvailable: builderAvailable, isFullscreen: isFullscreen, isRefreshing: isRefreshing, labels: effectiveLabels, onRefresh: refreshView, onEnterBuildMode: () => setBuildMode(true), onToggleFullscreen: toggleFullscreen }), _jsx(StepErrors, { hidden: buildMode, errors: viewData.context.errors }), _jsx(AppQueryProvider, { callTool: callToolFn, children: _jsx(ViewBody, { buildMode: buildMode, viewData: viewData, widgets: widgets, callTool: callToolFn, onExit: exitBuildMode }) })] }));
|
|
194
|
+
return (_jsx("div", { ref: frameRef, tabIndex: -1, "data-slot": "mcp-app-view", className: "outline-hidden", children: _jsxs("main", { style: {
|
|
195
|
+
// Fullscreen: the view owns the viewport and scrolls itself. Inline:
|
|
196
|
+
// the host sizes us from our intrinsic height (bootstrapView's
|
|
197
|
+
// auto-resize), so no overflow clipping there.
|
|
198
|
+
...(fullscreen.isFullscreen ? { minHeight: "100vh", overflowY: "auto" } : null),
|
|
199
|
+
paddingTop: safeArea.top,
|
|
200
|
+
paddingRight: safeArea.right,
|
|
201
|
+
paddingBottom: safeArea.bottom,
|
|
202
|
+
paddingLeft: safeArea.left,
|
|
203
|
+
}, children: [_jsx(ViewToolbar, { hidden: buildMode, viewData: viewData, builderAvailable: builderEnabled ?? viewData.builderAvailable ?? false, isFullscreen: fullscreen.isFullscreen, canFullscreen: fullscreen.canFullscreen, isRefreshing: isRefreshing, labels: L, titleMode: titleMode, titleLevel: titleLevel, renderTitle: renderTitle, onRefresh: refreshView, onEnterBuildMode: () => setBuildMode(true), onToggleFullscreen: fullscreen.toggle }), _jsx(StepErrors, { hidden: buildMode, errors: viewData.context.errors, steps: viewData._refreshParams?.steps, labels: L, describeStep: describeStep, onRetry: viewData._refreshParams ? () => void refreshView() : undefined }), _jsx(AppQueryProvider, { callTool: callToolFn, children: _jsx(ViewBody, { buildMode: buildMode, viewData: viewData, widgets: widgets, callTool: callToolFn, builderLabels: builderLabels, onExit: exitBuildMode }) })] }) }));
|
|
158
204
|
}
|
|
159
205
|
//# sourceMappingURL=mcp-app-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-view.js","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"mcp-app-view.js","sourceRoot":"","sources":["../../src/app/mcp-app-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OA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,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAC/B,KAAK,EAAE,QAAQ,CAAC,cAAc,EAAE,KAAK,EACrC,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,GACvE,EAEF,KAAC,gBAAgB,IAAC,QAAQ,EAAE,UAAU,YACpC,KAAC,QAAQ,IACP,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,aAAa,GACrB,GACe,IACd,GACH,CACP,CAAA;AACH,CAAC"}
|
|
@@ -2,7 +2,8 @@ import { type McpAppViewProps } from "./mcp-app-view.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Consumer-facing root for a toolkit-rendered MCP App. Composes the mcp-use
|
|
4
4
|
* 2.x view plumbing around `McpAppView`: `ThemeProvider` applies the host's
|
|
5
|
-
* theme/style variables to the document
|
|
5
|
+
* theme/style variables to the document (with the host's font kept behind
|
|
6
|
+
* Geist, see `adoptHostFontVariables`), and `McpUseHostBridgeProvider`
|
|
6
7
|
* installs the `HostBridge` (and view-scope flag) every toolkit widget below
|
|
7
8
|
* resolves through `useHostBridge()`.
|
|
8
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-toolkit-app.d.ts","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-toolkit-app.d.ts","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAsBpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,+BAUnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAE/D"}
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
import { ThemeProvider, bootstrapView, useHostContext } from "mcp-use/react";
|
|
4
|
+
import { adoptHostFontVariables } from "../theme/host-fonts.js";
|
|
3
5
|
import { McpAppView } from "./mcp-app-view.js";
|
|
4
6
|
import { McpUseHostBridgeProvider } from "./mcp-use-host-bridge.js";
|
|
7
|
+
/**
|
|
8
|
+
* Keeps Geist first when the host sends its font. mcp-use's `ThemeProvider`
|
|
9
|
+
* writes the host's SEP-1865 style variables inline on `<html>`, including
|
|
10
|
+
* `--font-sans`/`--font-mono`, which share their names with the toolkit's font
|
|
11
|
+
* roles and would replace the Geist-first stacks whole. This component sits
|
|
12
|
+
* ABOVE that provider on purpose: a parent's layout effect runs after its
|
|
13
|
+
* children's, so the host variables are already applied when it moves the
|
|
14
|
+
* font pair into the fallback slot (`adoptHostFontVariables`). Both effects
|
|
15
|
+
* key on the same host-context snapshot, so they run in the same commit.
|
|
16
|
+
*/
|
|
17
|
+
function HostFontRoles({ children }) {
|
|
18
|
+
const { hostContext } = useHostContext();
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
if (typeof document === "undefined")
|
|
21
|
+
return;
|
|
22
|
+
adoptHostFontVariables(document.documentElement.style, hostContext?.styles?.variables);
|
|
23
|
+
}, [hostContext]);
|
|
24
|
+
return children;
|
|
25
|
+
}
|
|
5
26
|
/**
|
|
6
27
|
* Consumer-facing root for a toolkit-rendered MCP App. Composes the mcp-use
|
|
7
28
|
* 2.x view plumbing around `McpAppView`: `ThemeProvider` applies the host's
|
|
8
|
-
* theme/style variables to the document
|
|
29
|
+
* theme/style variables to the document (with the host's font kept behind
|
|
30
|
+
* Geist, see `adoptHostFontVariables`), and `McpUseHostBridgeProvider`
|
|
9
31
|
* installs the `HostBridge` (and view-scope flag) every toolkit widget below
|
|
10
32
|
* resolves through `useHostBridge()`.
|
|
11
33
|
*
|
|
@@ -15,7 +37,7 @@ import { McpUseHostBridgeProvider } from "./mcp-use-host-bridge.js";
|
|
|
15
37
|
* composing a custom view under your own `bootstrapView` call.
|
|
16
38
|
*/
|
|
17
39
|
export function McpToolkitApp(props) {
|
|
18
|
-
return (_jsx(ThemeProvider, { children: _jsx(McpUseHostBridgeProvider, { children: _jsx(McpAppView, { ...props }) }) }));
|
|
40
|
+
return (_jsx(HostFontRoles, { children: _jsx(ThemeProvider, { children: _jsx(McpUseHostBridgeProvider, { children: _jsx(McpAppView, { ...props }) }) }) }));
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
21
43
|
* Mount the toolkit app as the document's MCP App view — the bundle entry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-toolkit-app.js","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"mcp-toolkit-app.js","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,OAAO,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAwB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAEnE;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,EAAE,QAAQ,EAA2B;IAC1D,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAA;IACxC,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAM;QAC3C,sBAAsB,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IACxF,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IACjB,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO,CACL,KAAC,aAAa,cACZ,KAAC,aAAa,cACZ,KAAC,wBAAwB,cACvB,KAAC,UAAU,OAAK,KAAK,GAAI,GACA,GACb,GACF,CACjB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB;IACvD,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAC,aAAa,OAAK,KAAK,GAAI,EAAE,CAAC,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import { type RenderCallStatus, type ViewLifecycle } from "./view-lifecycle.js";
|
|
3
|
+
export interface UseViewLifecycleOptions<T> {
|
|
4
|
+
hasViewData: boolean;
|
|
5
|
+
callStatus: RenderCallStatus;
|
|
6
|
+
cancelled: boolean;
|
|
7
|
+
callError: unknown;
|
|
8
|
+
recoveryFailed: boolean;
|
|
9
|
+
/** The originating tool (`hostContext.toolInfo`); a retry needs it. */
|
|
10
|
+
toolName: string | undefined;
|
|
11
|
+
toolInput: Record<string, unknown> | null | undefined;
|
|
12
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
13
|
+
isValid: (value: unknown) => value is T;
|
|
14
|
+
/** Receives the payload of a successful retry. */
|
|
15
|
+
onResult: (data: T) => void;
|
|
16
|
+
slowHintAfterMs: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Drives the {@link resolveViewLifecycle} state machine: owns the retry and
|
|
20
|
+
* the slow-hint timer, and returns the current phase plus `retry()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useViewLifecycle<T>(options: UseViewLifecycleOptions<T>): {
|
|
23
|
+
lifecycle: ViewLifecycle;
|
|
24
|
+
retry: () => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Keeps keyboard focus in the view across a user retry: the pressed button
|
|
28
|
+
* unmounts when the view starts waiting, so focus moves to the frame (a
|
|
29
|
+
* `tabIndex={-1}` container), then to the new retry button when the retry
|
|
30
|
+
* failed, or stays on the frame once the view rendered (see
|
|
31
|
+
* {@link retryFocusTarget}). Focus the user moved elsewhere meanwhile is left
|
|
32
|
+
* alone. Returns the frame ref and `retry` wrapped to start the hand-off.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useRetryFocus(phase: ViewLifecycle["phase"], retry: () => void): {
|
|
35
|
+
frameRef: RefObject<HTMLDivElement | null>;
|
|
36
|
+
retry: () => void;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=use-view-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-view-lifecycle.d.ts","sourceRoot":"","sources":["../../src/app/use-view-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5F,OAAO,EASL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAA;AAE5B,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,EAAE,OAAO,CAAA;IACvB,uEAAuE;IACvE,QAAQ,EAAE,MAA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