@blade-hq/agent-react 2612.0.0-beta.67 → 2612.0.0-beta.69
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 +2 -0
- package/dist/{chunk-MAFNMG2O.js → chunk-2DPLLZOU.js} +18 -13
- package/dist/{chunk-MAFNMG2O.js.map → chunk-2DPLLZOU.js.map} +1 -1
- package/dist/{chunk-N576N2XO.js → chunk-7MCGQH34.js} +12 -9
- package/dist/chunk-7MCGQH34.js.map +1 -0
- package/dist/{chunk-UC7SY3G5.js → chunk-HCW7SI5Q.js} +333 -269
- package/dist/chunk-HCW7SI5Q.js.map +1 -0
- package/dist/{chunk-X66C66OQ.js → chunk-J72ZLILV.js} +287 -67
- package/dist/chunk-J72ZLILV.js.map +1 -0
- package/dist/{chunk-HS5G33FO.js → chunk-QIR73CES.js} +1031 -8
- package/dist/chunk-QIR73CES.js.map +1 -0
- package/dist/{chunk-VSIUEXGV.js → chunk-WRIMPZPN.js} +12 -962
- package/dist/chunk-WRIMPZPN.js.map +1 -0
- package/dist/{chunk-XV6AO37F.js → chunk-XJ6ZA6LN.js} +9 -9
- package/dist/{chunk-U3RHQHI6.js → chunk-XP6T6SHZ.js} +48 -48
- package/dist/components/AccountConnectors.d.ts +1 -1
- package/dist/components/ManagedConnection.d.ts +0 -1
- package/dist/components/McpAppFrame.d.ts +17 -0
- package/dist/components/SessionPluginIcon.d.ts +1 -0
- package/dist/connectors.js +2 -2
- package/dist/index.js +7 -7
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +10 -8
- package/dist/internal.js.map +1 -1
- package/dist/questions.js +4 -5
- package/dist/questions.js.map +1 -1
- package/dist/rich-input.js +20 -20
- package/dist/style.full.css +1 -1
- package/dist/tool-details.js +4 -4
- package/node_modules/@modelcontextprotocol/ext-apps/LICENSE +216 -0
- package/node_modules/@modelcontextprotocol/ext-apps/README.md +284 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/docs/patterns.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.d.ts +1348 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-with-deps.js +82 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.d.ts +1214 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/constants.d.ts +65 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.d.ts +47 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.d.ts +1047 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.json +6170 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.test.d.ts +41 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/interop-v1.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.d.ts +66 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.d.ts +126 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.d.ts +37 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/react-with-deps.js +82 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.d.ts +115 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.d.ts +54 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.d.ts +44 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.d.ts +113 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.d.ts +381 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/spec.types.d.ts +698 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/standard-schema.d.ts +23 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.d.ts +184 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/types.d.ts +33 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/wire-compat.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/package.json +144 -0
- package/node_modules/@standard-schema/spec/LICENSE +21 -0
- package/node_modules/@standard-schema/spec/README.md +198 -0
- package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
- package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.js +0 -0
- package/node_modules/@standard-schema/spec/package.json +52 -0
- package/package.json +6 -2
- package/dist/chunk-HS5G33FO.js.map +0 -1
- package/dist/chunk-N576N2XO.js.map +0 -1
- package/dist/chunk-UC7SY3G5.js.map +0 -1
- package/dist/chunk-VSIUEXGV.js.map +0 -1
- package/dist/chunk-X66C66OQ.js.map +0 -1
- /package/dist/{chunk-XV6AO37F.js.map → chunk-XJ6ZA6LN.js.map} +0 -0
- /package/dist/{chunk-U3RHQHI6.js.map → chunk-XP6T6SHZ.js.map} +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Implementation } from "@modelcontextprotocol/client";
|
|
2
|
+
import { App, AppOptions, McpUiAppCapabilities } from "../app.js";
|
|
3
|
+
export * from "../app.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring the {@link useApp `useApp`} hook.
|
|
6
|
+
*
|
|
7
|
+
* The `autoResize` and `strict` options are forwarded to the underlying
|
|
8
|
+
* {@link App `App`} instance. For other {@link AppOptions `AppOptions`},
|
|
9
|
+
* create the `App` manually instead of using this hook.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link useApp `useApp`} for the hook that uses these options
|
|
12
|
+
* @see {@link useAutoResize `useAutoResize`} for manual auto-resize control with custom `App` options
|
|
13
|
+
*/
|
|
14
|
+
export interface UseAppOptions extends Pick<AppOptions, "autoResize" | "strict"> {
|
|
15
|
+
/** App identification (name and version) */
|
|
16
|
+
appInfo: Implementation;
|
|
17
|
+
/**
|
|
18
|
+
* Declares what features this app supports.
|
|
19
|
+
*/
|
|
20
|
+
capabilities: McpUiAppCapabilities;
|
|
21
|
+
/**
|
|
22
|
+
* Called after {@link App `App`} is created but before connection.
|
|
23
|
+
*
|
|
24
|
+
* Use this to register request/notification handlers that need to be in place
|
|
25
|
+
* before the initialization handshake completes.
|
|
26
|
+
*
|
|
27
|
+
* @param app - The newly created `App` instance
|
|
28
|
+
*
|
|
29
|
+
* @example Register an event handler
|
|
30
|
+
* ```tsx source="./useApp.examples.tsx#useApp_registerHandler"
|
|
31
|
+
* useApp({
|
|
32
|
+
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
33
|
+
* capabilities: {},
|
|
34
|
+
* onAppCreated: (app) => {
|
|
35
|
+
* app.ontoolresult = (result) => {
|
|
36
|
+
* console.log("Tool result:", result);
|
|
37
|
+
* };
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
onAppCreated?: (app: App) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* State returned by the {@link useApp `useApp`} hook.
|
|
46
|
+
*/
|
|
47
|
+
export interface AppState {
|
|
48
|
+
/** The connected {@link App `App`} instance, null during initialization */
|
|
49
|
+
app: App | null;
|
|
50
|
+
/** Whether initialization completed successfully */
|
|
51
|
+
isConnected: boolean;
|
|
52
|
+
/** Connection error if initialization failed, null otherwise */
|
|
53
|
+
error: Error | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* React hook to create and connect an MCP App.
|
|
57
|
+
*
|
|
58
|
+
* This hook manages {@link App `App`} creation and connection. It automatically
|
|
59
|
+
* creates a {@link PostMessageTransport `PostMessageTransport`} to window.parent and handles
|
|
60
|
+
* initialization.
|
|
61
|
+
*
|
|
62
|
+
* This hook is part of the optional React integration. The core SDK (`App`,
|
|
63
|
+
* `PostMessageTransport`) is framework-agnostic and can be used with any UI
|
|
64
|
+
* framework or vanilla JavaScript.
|
|
65
|
+
*
|
|
66
|
+
* **Important**: The hook intentionally does NOT re-run when options change
|
|
67
|
+
* to avoid reconnection loops. Options are only used during the initial mount.
|
|
68
|
+
* Furthermore, the `App` instance is NOT closed on unmount. This avoids cleanup
|
|
69
|
+
* issues during React Strict Mode's double-mount cycle. If you need to
|
|
70
|
+
* explicitly close the `App`, call {@link App.close `App.close`} manually.
|
|
71
|
+
*
|
|
72
|
+
* @param options - Configuration for the app
|
|
73
|
+
* @returns Current connection state and app instance. If connection fails during
|
|
74
|
+
* initialization, the `error` field will contain the error (typically connection
|
|
75
|
+
* timeouts, initialization handshake failures, or transport errors).
|
|
76
|
+
*
|
|
77
|
+
* @example Basic usage of useApp hook with common event handlers
|
|
78
|
+
* ```tsx source="./useApp.examples.tsx#useApp_basicUsage"
|
|
79
|
+
* function MyApp() {
|
|
80
|
+
* const [hostContext, setHostContext] = useState<
|
|
81
|
+
* McpUiHostContext | undefined
|
|
82
|
+
* >(undefined);
|
|
83
|
+
*
|
|
84
|
+
* const { app, isConnected, error } = useApp({
|
|
85
|
+
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
86
|
+
* capabilities: {},
|
|
87
|
+
* onAppCreated: (app) => {
|
|
88
|
+
* app.ontoolinput = (input) => {
|
|
89
|
+
* console.log("Tool input:", input);
|
|
90
|
+
* };
|
|
91
|
+
* app.ontoolresult = (result) => {
|
|
92
|
+
* console.log("Tool result:", result);
|
|
93
|
+
* };
|
|
94
|
+
* app.ontoolcancelled = (params) => {
|
|
95
|
+
* console.log("Tool cancelled:", params.reason);
|
|
96
|
+
* };
|
|
97
|
+
* app.onerror = (error) => {
|
|
98
|
+
* console.log("Error:", error);
|
|
99
|
+
* };
|
|
100
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
101
|
+
* setHostContext((prev) => ({ ...prev, ...ctx }));
|
|
102
|
+
* };
|
|
103
|
+
* },
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
107
|
+
* if (!isConnected) return <div>Connecting...</div>;
|
|
108
|
+
* return <div>Theme: {hostContext?.theme}</div>;
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @see {@link App.connect `App.connect`} for the underlying connection method
|
|
113
|
+
* @see {@link useAutoResize `useAutoResize`} for manual auto-resize control when using custom App options
|
|
114
|
+
*/
|
|
115
|
+
export declare function useApp({ appInfo, capabilities, onAppCreated, autoResize, strict, }: UseAppOptions): AppState;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { App } from "../app.js";
|
|
3
|
+
/**
|
|
4
|
+
* React hook that automatically reports UI size changes to the host.
|
|
5
|
+
*
|
|
6
|
+
* Uses `ResizeObserver` to watch `document.body` and `document.documentElement` for
|
|
7
|
+
* size changes and sends `ui/notifications/size-changed` notifications.
|
|
8
|
+
*
|
|
9
|
+
* The hook automatically cleans up the `ResizeObserver` when the component unmounts.
|
|
10
|
+
*
|
|
11
|
+
* **Note**: This hook is rarely needed since the {@link useApp `useApp`} hook automatically enables
|
|
12
|
+
* auto-resize by default. This hook is provided for advanced cases where you
|
|
13
|
+
* create the {@link App `App`} manually with `autoResize: false` and want to add auto-resize
|
|
14
|
+
* behavior later.
|
|
15
|
+
*
|
|
16
|
+
* @param app - The connected {@link App `App`} instance, or null during initialization
|
|
17
|
+
* @param elementRef - Currently unused. The hook always observes `document.body`
|
|
18
|
+
* and `document.documentElement` regardless of this value. Passing a ref will
|
|
19
|
+
* cause unnecessary effect re-runs; omit this parameter.
|
|
20
|
+
*
|
|
21
|
+
* @example Manual App creation with custom auto-resize control
|
|
22
|
+
* ```tsx source="./useAutoResize.examples.tsx#useAutoResize_manualApp"
|
|
23
|
+
* function MyComponent() {
|
|
24
|
+
* // For custom App options, create App manually instead of using useApp
|
|
25
|
+
* const [app, setApp] = useState<App | null>(null);
|
|
26
|
+
* const [error, setError] = useState<Error | null>(null);
|
|
27
|
+
*
|
|
28
|
+
* useEffect(() => {
|
|
29
|
+
* const myApp = new App(
|
|
30
|
+
* { name: "MyApp", version: "1.0.0" },
|
|
31
|
+
* {}, // capabilities
|
|
32
|
+
* { autoResize: false }, // Disable default auto-resize
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* const transport = new PostMessageTransport(window.parent, window.parent);
|
|
36
|
+
* myApp
|
|
37
|
+
* .connect(transport)
|
|
38
|
+
* .then(() => setApp(myApp))
|
|
39
|
+
* .catch((err) => setError(err));
|
|
40
|
+
* }, []);
|
|
41
|
+
*
|
|
42
|
+
* // Add manual auto-resize control
|
|
43
|
+
* useAutoResize(app);
|
|
44
|
+
*
|
|
45
|
+
* if (error) return <div>Connection failed: {error.message}</div>;
|
|
46
|
+
* return <div>My content</div>;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see {@link App.setupSizeChangedNotifications `App.setupSizeChangedNotifications`} for the underlying implementation
|
|
51
|
+
* @see {@link useApp `useApp`} which enables auto-resize by default
|
|
52
|
+
* @see {@link App `App`} constructor for configuring `autoResize` option
|
|
53
|
+
*/
|
|
54
|
+
export declare function useAutoResize(app: App | null, elementRef?: RefObject<HTMLElement | null>): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { McpUiTheme } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* React hook that provides the current document theme reactively.
|
|
4
|
+
*
|
|
5
|
+
* Uses a `MutationObserver` to watch for changes to the `data-theme` attribute
|
|
6
|
+
* or `class` on `document.documentElement`. When the theme changes (e.g., from
|
|
7
|
+
* host context updates), the hook automatically re-renders your component with
|
|
8
|
+
* the new theme value.
|
|
9
|
+
*
|
|
10
|
+
* The `MutationObserver` is automatically disconnected when the component unmounts.
|
|
11
|
+
*
|
|
12
|
+
* @returns The current theme ("light" or "dark")
|
|
13
|
+
*
|
|
14
|
+
* @example Conditionally render based on theme
|
|
15
|
+
* ```tsx source="./useDocumentTheme.examples.tsx#useDocumentTheme_conditionalRender"
|
|
16
|
+
* function MyApp() {
|
|
17
|
+
* const theme = useDocumentTheme();
|
|
18
|
+
*
|
|
19
|
+
* return <div>{theme === "dark" ? <DarkIcon /> : <LightIcon />}</div>;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Use with theme-aware styling
|
|
24
|
+
* ```tsx source="./useDocumentTheme.examples.tsx#useDocumentTheme_themedButton"
|
|
25
|
+
* function ThemedButton() {
|
|
26
|
+
* const theme = useDocumentTheme();
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <button
|
|
30
|
+
* style={{
|
|
31
|
+
* background: theme === "dark" ? "#333" : "#fff",
|
|
32
|
+
* color: theme === "dark" ? "#fff" : "#333",
|
|
33
|
+
* }}
|
|
34
|
+
* >
|
|
35
|
+
* Click me
|
|
36
|
+
* </button>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @see {@link getDocumentTheme `getDocumentTheme`} for the underlying function
|
|
42
|
+
* @see {@link applyDocumentTheme `applyDocumentTheme`} to set the theme
|
|
43
|
+
*/
|
|
44
|
+
export declare function useDocumentTheme(): McpUiTheme;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { App } from "../app.js";
|
|
2
|
+
import { McpUiHostContext } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* React hook that applies host style variables and theme as CSS custom properties.
|
|
5
|
+
*
|
|
6
|
+
* This hook listens to host context changes and automatically applies:
|
|
7
|
+
* - `styles.variables` CSS variables to `document.documentElement` (e.g., `--color-background-primary`)
|
|
8
|
+
* - `theme` via `color-scheme` CSS property, enabling `light-dark()` CSS function support
|
|
9
|
+
*
|
|
10
|
+
* The hook also applies styles and theme from the initial host context when
|
|
11
|
+
* the app first connects.
|
|
12
|
+
*
|
|
13
|
+
* **Note:** If the host provides style values using CSS `light-dark()` function,
|
|
14
|
+
* this hook ensures they work correctly by setting the `color-scheme` property
|
|
15
|
+
* based on the host's theme preference.
|
|
16
|
+
*
|
|
17
|
+
* @param app - The connected {@link App `App`} instance, or null during initialization
|
|
18
|
+
* @param initialContext - Initial host context from the connection (optional).
|
|
19
|
+
* If provided, styles and theme will be applied immediately on mount.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx source="./useHostStyles.examples.tsx#useHostStyleVariables_basicUsage"
|
|
23
|
+
* function MyApp() {
|
|
24
|
+
* const { app } = useApp({
|
|
25
|
+
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
26
|
+
* capabilities: {},
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Apply host styles - pass initial context to apply styles from connect() immediately
|
|
30
|
+
* useHostStyleVariables(app, app?.getHostContext());
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div style={{ background: "var(--color-background-primary)" }}>
|
|
34
|
+
* Hello!
|
|
35
|
+
* </div>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @see {@link applyHostStyleVariables `applyHostStyleVariables`} for the underlying styles function
|
|
41
|
+
* @see {@link applyDocumentTheme `applyDocumentTheme`} for the underlying theme function
|
|
42
|
+
* @see {@link useHostFonts `useHostFonts`} for applying host fonts
|
|
43
|
+
* @see {@link McpUiStyles `McpUiStyles`} for available CSS variables
|
|
44
|
+
*/
|
|
45
|
+
export declare function useHostStyleVariables(app: App | null, initialContext?: McpUiHostContext | null): void;
|
|
46
|
+
/**
|
|
47
|
+
* React hook that applies host fonts from CSS.
|
|
48
|
+
*
|
|
49
|
+
* This hook listens to host context changes and automatically applies:
|
|
50
|
+
* - `styles.css.fonts` as a `<style>` tag for custom fonts
|
|
51
|
+
*
|
|
52
|
+
* The CSS can contain `@font-face` rules for self-hosted fonts,
|
|
53
|
+
* `@import` statements for Google Fonts or other font services, or both.
|
|
54
|
+
*
|
|
55
|
+
* The hook also applies fonts from the initial host context when
|
|
56
|
+
* the app first connects.
|
|
57
|
+
*
|
|
58
|
+
* @param app - The connected {@link App `App`} instance, or null during initialization
|
|
59
|
+
* @param initialContext - Initial host context from the connection (optional).
|
|
60
|
+
* If provided, fonts will be applied immediately on mount.
|
|
61
|
+
*
|
|
62
|
+
* @example Basic usage with useApp
|
|
63
|
+
* ```tsx source="./useHostStyles.examples.tsx#useHostFonts_basicUsage"
|
|
64
|
+
* function MyApp() {
|
|
65
|
+
* const { app } = useApp({
|
|
66
|
+
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
67
|
+
* capabilities: {},
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Apply host fonts - pass initial context to apply fonts from connect() immediately
|
|
71
|
+
* useHostFonts(app, app?.getHostContext());
|
|
72
|
+
*
|
|
73
|
+
* return <div style={{ fontFamily: "var(--font-sans)" }}>Hello!</div>;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @see {@link applyHostFonts `applyHostFonts`} for the underlying fonts function
|
|
78
|
+
* @see {@link useHostStyleVariables `useHostStyleVariables`} for applying style variables and theme
|
|
79
|
+
*/
|
|
80
|
+
export declare function useHostFonts(app: App | null, initialContext?: McpUiHostContext | null): void;
|
|
81
|
+
/**
|
|
82
|
+
* Applies all host styling (CSS variables, theme, and fonts) to match the host application.
|
|
83
|
+
*
|
|
84
|
+
* This is a convenience hook that combines {@link useHostStyleVariables `useHostStyleVariables`} and
|
|
85
|
+
* {@link useHostFonts `useHostFonts`}. Use the individual hooks if you need more control.
|
|
86
|
+
*
|
|
87
|
+
* @param app - The connected {@link App `App`} instance, or null during initialization
|
|
88
|
+
* @param initialContext - Initial host context from the connection (optional).
|
|
89
|
+
* Pass `app?.getHostContext()` to apply styles immediately on mount.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx source="./useHostStyles.examples.tsx#useHostStyles_basicUsage"
|
|
93
|
+
* function MyApp() {
|
|
94
|
+
* const { app } = useApp({
|
|
95
|
+
* appInfo: { name: "MyApp", version: "1.0.0" },
|
|
96
|
+
* capabilities: {},
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // Apply all host styles - pass initial context to apply styles from connect() immediately
|
|
100
|
+
* useHostStyles(app, app?.getHostContext());
|
|
101
|
+
*
|
|
102
|
+
* return (
|
|
103
|
+
* <div style={{ background: "var(--color-background-primary)" }}>
|
|
104
|
+
* Hello!
|
|
105
|
+
* </div>
|
|
106
|
+
* );
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see {@link useHostStyleVariables `useHostStyleVariables`} for style variables and theme only
|
|
111
|
+
* @see {@link useHostFonts `useHostFonts`} for fonts only
|
|
112
|
+
*/
|
|
113
|
+
export declare function useHostStyles(app: App | null, initialContext?: McpUiHostContext | null): void;
|