@frontmcp/ui 0.6.1 → 0.6.3

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.
Files changed (292) hide show
  1. package/bridge/core/bridge-factory.d.ts +1 -0
  2. package/bridge/core/bridge-factory.d.ts.map +1 -1
  3. package/bridge/index.d.ts +1 -1
  4. package/bridge/index.d.ts.map +1 -1
  5. package/bridge/index.js +39 -881
  6. package/bundler/browser-components.d.ts +42 -0
  7. package/bundler/browser-components.d.ts.map +1 -0
  8. package/bundler/bundler.d.ts +78 -4
  9. package/bundler/bundler.d.ts.map +1 -1
  10. package/bundler/index.d.ts +8 -8
  11. package/bundler/index.d.ts.map +1 -1
  12. package/bundler/index.js +1315 -1854
  13. package/bundler/types.d.ts +188 -7
  14. package/bundler/types.d.ts.map +1 -1
  15. package/esm/bridge/{index.js → index.mjs} +40 -877
  16. package/esm/bundler/{index.js → index.mjs} +1391 -1895
  17. package/esm/{index.js → index.mjs} +215 -3091
  18. package/esm/layouts/{index.js → index.mjs} +3 -3
  19. package/esm/package.json +17 -18
  20. package/esm/react/index.mjs +1183 -0
  21. package/esm/renderers/index.mjs +611 -0
  22. package/esm/universal/{index.js → index.mjs} +266 -70
  23. package/index.d.ts +1 -4
  24. package/index.d.ts.map +1 -1
  25. package/index.js +208 -3113
  26. package/layouts/base.d.ts.map +1 -1
  27. package/layouts/index.js +3 -3
  28. package/layouts/presets.d.ts.map +1 -1
  29. package/package.json +9 -8
  30. package/react/Badge.d.ts.map +1 -1
  31. package/react/hooks/context.d.ts.map +1 -1
  32. package/react/index.d.ts +0 -1
  33. package/react/index.d.ts.map +1 -1
  34. package/react/index.js +57 -2001
  35. package/react/types.d.ts.map +1 -1
  36. package/renderers/index.d.ts +9 -4
  37. package/renderers/index.d.ts.map +1 -1
  38. package/renderers/index.js +328 -88
  39. package/renderers/mdx.renderer.d.ts +99 -0
  40. package/renderers/mdx.renderer.d.ts.map +1 -0
  41. package/renderers/react.renderer.d.ts +22 -13
  42. package/renderers/react.renderer.d.ts.map +1 -1
  43. package/renderers/transpiler.d.ts +49 -0
  44. package/renderers/transpiler.d.ts.map +1 -0
  45. package/universal/cached-runtime.d.ts +25 -1
  46. package/universal/cached-runtime.d.ts.map +1 -1
  47. package/universal/index.js +266 -70
  48. package/universal/runtime-builder.d.ts.map +1 -1
  49. package/universal/types.d.ts.map +1 -1
  50. package/web-components/elements/fmcp-input.d.ts.map +1 -1
  51. package/web-components/elements/fmcp-select.d.ts.map +1 -1
  52. package/web-components/index.d.ts +0 -1
  53. package/web-components/index.d.ts.map +1 -1
  54. package/bundler/cache.d.ts +0 -173
  55. package/bundler/cache.d.ts.map +0 -1
  56. package/bundler/file-cache/component-builder.d.ts +0 -167
  57. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  58. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  59. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  60. package/bundler/file-cache/index.d.ts +0 -12
  61. package/bundler/file-cache/index.d.ts.map +0 -1
  62. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  63. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  64. package/bundler/file-cache/storage/index.d.ts +0 -11
  65. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  66. package/bundler/file-cache/storage/interface.d.ts +0 -152
  67. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  68. package/bundler/file-cache/storage/redis.d.ts +0 -139
  69. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  70. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  71. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  72. package/bundler/sandbox/executor.d.ts +0 -14
  73. package/bundler/sandbox/executor.d.ts.map +0 -1
  74. package/bundler/sandbox/policy.d.ts +0 -62
  75. package/bundler/sandbox/policy.d.ts.map +0 -1
  76. package/esm/bridge/adapters/base-adapter.d.ts +0 -104
  77. package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
  78. package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
  79. package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
  80. package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
  81. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
  82. package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
  83. package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
  84. package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
  85. package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
  86. package/esm/bridge/adapters/index.d.ts +0 -26
  87. package/esm/bridge/adapters/index.d.ts.map +0 -1
  88. package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
  89. package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
  90. package/esm/bridge/core/adapter-registry.d.ts +0 -122
  91. package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
  92. package/esm/bridge/core/bridge-factory.d.ts +0 -199
  93. package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
  94. package/esm/bridge/core/index.d.ts +0 -10
  95. package/esm/bridge/core/index.d.ts.map +0 -1
  96. package/esm/bridge/index.d.ts +0 -62
  97. package/esm/bridge/index.d.ts.map +0 -1
  98. package/esm/bridge/runtime/iife-generator.d.ts +0 -62
  99. package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
  100. package/esm/bridge/runtime/index.d.ts +0 -10
  101. package/esm/bridge/runtime/index.d.ts.map +0 -1
  102. package/esm/bridge/types.d.ts +0 -386
  103. package/esm/bridge/types.d.ts.map +0 -1
  104. package/esm/bundler/bundler.d.ts +0 -208
  105. package/esm/bundler/bundler.d.ts.map +0 -1
  106. package/esm/bundler/cache.d.ts +0 -173
  107. package/esm/bundler/cache.d.ts.map +0 -1
  108. package/esm/bundler/file-cache/component-builder.d.ts +0 -167
  109. package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
  110. package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
  111. package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  112. package/esm/bundler/file-cache/index.d.ts +0 -12
  113. package/esm/bundler/file-cache/index.d.ts.map +0 -1
  114. package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
  115. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  116. package/esm/bundler/file-cache/storage/index.d.ts +0 -11
  117. package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
  118. package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
  119. package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
  120. package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
  121. package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
  122. package/esm/bundler/index.d.ts +0 -43
  123. package/esm/bundler/index.d.ts.map +0 -1
  124. package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
  125. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  126. package/esm/bundler/sandbox/executor.d.ts +0 -14
  127. package/esm/bundler/sandbox/executor.d.ts.map +0 -1
  128. package/esm/bundler/sandbox/policy.d.ts +0 -62
  129. package/esm/bundler/sandbox/policy.d.ts.map +0 -1
  130. package/esm/bundler/types.d.ts +0 -702
  131. package/esm/bundler/types.d.ts.map +0 -1
  132. package/esm/components/alert.d.ts +0 -66
  133. package/esm/components/alert.d.ts.map +0 -1
  134. package/esm/components/alert.schema.d.ts +0 -98
  135. package/esm/components/alert.schema.d.ts.map +0 -1
  136. package/esm/components/avatar.d.ts +0 -77
  137. package/esm/components/avatar.d.ts.map +0 -1
  138. package/esm/components/avatar.schema.d.ts +0 -170
  139. package/esm/components/avatar.schema.d.ts.map +0 -1
  140. package/esm/components/badge.d.ts +0 -64
  141. package/esm/components/badge.d.ts.map +0 -1
  142. package/esm/components/badge.schema.d.ts +0 -91
  143. package/esm/components/badge.schema.d.ts.map +0 -1
  144. package/esm/components/button.d.ts +0 -100
  145. package/esm/components/button.d.ts.map +0 -1
  146. package/esm/components/button.schema.d.ts +0 -120
  147. package/esm/components/button.schema.d.ts.map +0 -1
  148. package/esm/components/card.d.ts +0 -53
  149. package/esm/components/card.d.ts.map +0 -1
  150. package/esm/components/card.schema.d.ts +0 -93
  151. package/esm/components/card.schema.d.ts.map +0 -1
  152. package/esm/components/form.d.ts +0 -212
  153. package/esm/components/form.d.ts.map +0 -1
  154. package/esm/components/form.schema.d.ts +0 -365
  155. package/esm/components/form.schema.d.ts.map +0 -1
  156. package/esm/components/index.d.ts +0 -29
  157. package/esm/components/index.d.ts.map +0 -1
  158. package/esm/components/list.d.ts +0 -121
  159. package/esm/components/list.d.ts.map +0 -1
  160. package/esm/components/list.schema.d.ts +0 -129
  161. package/esm/components/list.schema.d.ts.map +0 -1
  162. package/esm/components/modal.d.ts +0 -100
  163. package/esm/components/modal.d.ts.map +0 -1
  164. package/esm/components/modal.schema.d.ts +0 -151
  165. package/esm/components/modal.schema.d.ts.map +0 -1
  166. package/esm/components/table.d.ts +0 -91
  167. package/esm/components/table.d.ts.map +0 -1
  168. package/esm/components/table.schema.d.ts +0 -123
  169. package/esm/components/table.schema.d.ts.map +0 -1
  170. package/esm/index.d.ts +0 -40
  171. package/esm/index.d.ts.map +0 -1
  172. package/esm/layouts/base.d.ts +0 -86
  173. package/esm/layouts/base.d.ts.map +0 -1
  174. package/esm/layouts/index.d.ts +0 -8
  175. package/esm/layouts/index.d.ts.map +0 -1
  176. package/esm/layouts/presets.d.ts +0 -134
  177. package/esm/layouts/presets.d.ts.map +0 -1
  178. package/esm/pages/consent.d.ts +0 -117
  179. package/esm/pages/consent.d.ts.map +0 -1
  180. package/esm/pages/error.d.ts +0 -101
  181. package/esm/pages/error.d.ts.map +0 -1
  182. package/esm/pages/index.d.ts +0 -9
  183. package/esm/pages/index.d.ts.map +0 -1
  184. package/esm/pages/index.js +0 -1036
  185. package/esm/react/Alert.d.ts +0 -101
  186. package/esm/react/Alert.d.ts.map +0 -1
  187. package/esm/react/Badge.d.ts +0 -100
  188. package/esm/react/Badge.d.ts.map +0 -1
  189. package/esm/react/Button.d.ts +0 -108
  190. package/esm/react/Button.d.ts.map +0 -1
  191. package/esm/react/Card.d.ts +0 -103
  192. package/esm/react/Card.d.ts.map +0 -1
  193. package/esm/react/hooks/context.d.ts +0 -179
  194. package/esm/react/hooks/context.d.ts.map +0 -1
  195. package/esm/react/hooks/index.d.ts +0 -42
  196. package/esm/react/hooks/index.d.ts.map +0 -1
  197. package/esm/react/hooks/tools.d.ts +0 -284
  198. package/esm/react/hooks/tools.d.ts.map +0 -1
  199. package/esm/react/index.d.ts +0 -80
  200. package/esm/react/index.d.ts.map +0 -1
  201. package/esm/react/index.js +0 -3124
  202. package/esm/react/types.d.ts +0 -105
  203. package/esm/react/types.d.ts.map +0 -1
  204. package/esm/react/utils.d.ts +0 -43
  205. package/esm/react/utils.d.ts.map +0 -1
  206. package/esm/render/index.d.ts +0 -8
  207. package/esm/render/index.d.ts.map +0 -1
  208. package/esm/render/prerender.d.ts +0 -57
  209. package/esm/render/prerender.d.ts.map +0 -1
  210. package/esm/renderers/index.d.ts +0 -21
  211. package/esm/renderers/index.d.ts.map +0 -1
  212. package/esm/renderers/index.js +0 -381
  213. package/esm/renderers/react.adapter.d.ts +0 -70
  214. package/esm/renderers/react.adapter.d.ts.map +0 -1
  215. package/esm/renderers/react.renderer.d.ts +0 -96
  216. package/esm/renderers/react.renderer.d.ts.map +0 -1
  217. package/esm/universal/UniversalApp.d.ts +0 -108
  218. package/esm/universal/UniversalApp.d.ts.map +0 -1
  219. package/esm/universal/cached-runtime.d.ts +0 -115
  220. package/esm/universal/cached-runtime.d.ts.map +0 -1
  221. package/esm/universal/context.d.ts +0 -122
  222. package/esm/universal/context.d.ts.map +0 -1
  223. package/esm/universal/index.d.ts +0 -57
  224. package/esm/universal/index.d.ts.map +0 -1
  225. package/esm/universal/renderers/html.renderer.d.ts +0 -37
  226. package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
  227. package/esm/universal/renderers/index.d.ts +0 -112
  228. package/esm/universal/renderers/index.d.ts.map +0 -1
  229. package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
  230. package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
  231. package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
  232. package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
  233. package/esm/universal/renderers/react.renderer.d.ts +0 -46
  234. package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
  235. package/esm/universal/runtime-builder.d.ts +0 -33
  236. package/esm/universal/runtime-builder.d.ts.map +0 -1
  237. package/esm/universal/store.d.ts +0 -135
  238. package/esm/universal/store.d.ts.map +0 -1
  239. package/esm/universal/types.d.ts +0 -199
  240. package/esm/universal/types.d.ts.map +0 -1
  241. package/esm/web-components/core/attribute-parser.d.ts +0 -82
  242. package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
  243. package/esm/web-components/core/base-element.d.ts +0 -197
  244. package/esm/web-components/core/base-element.d.ts.map +0 -1
  245. package/esm/web-components/core/index.d.ts +0 -9
  246. package/esm/web-components/core/index.d.ts.map +0 -1
  247. package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
  248. package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
  249. package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
  250. package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
  251. package/esm/web-components/elements/fmcp-button.d.ts +0 -117
  252. package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
  253. package/esm/web-components/elements/fmcp-card.d.ts +0 -53
  254. package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
  255. package/esm/web-components/elements/fmcp-input.d.ts +0 -96
  256. package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
  257. package/esm/web-components/elements/fmcp-select.d.ts +0 -100
  258. package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
  259. package/esm/web-components/elements/index.d.ts +0 -13
  260. package/esm/web-components/elements/index.d.ts.map +0 -1
  261. package/esm/web-components/index.d.ts +0 -50
  262. package/esm/web-components/index.d.ts.map +0 -1
  263. package/esm/web-components/register.d.ts +0 -57
  264. package/esm/web-components/register.d.ts.map +0 -1
  265. package/esm/web-components/types.d.ts +0 -122
  266. package/esm/web-components/types.d.ts.map +0 -1
  267. package/esm/widgets/index.d.ts +0 -8
  268. package/esm/widgets/index.d.ts.map +0 -1
  269. package/esm/widgets/index.js +0 -883
  270. package/esm/widgets/progress.d.ts +0 -133
  271. package/esm/widgets/progress.d.ts.map +0 -1
  272. package/esm/widgets/resource.d.ts +0 -163
  273. package/esm/widgets/resource.d.ts.map +0 -1
  274. package/pages/consent.d.ts +0 -117
  275. package/pages/consent.d.ts.map +0 -1
  276. package/pages/error.d.ts +0 -101
  277. package/pages/error.d.ts.map +0 -1
  278. package/pages/index.d.ts +0 -9
  279. package/pages/index.d.ts.map +0 -1
  280. package/pages/index.js +0 -1065
  281. package/react/utils.d.ts +0 -43
  282. package/react/utils.d.ts.map +0 -1
  283. package/widgets/index.d.ts +0 -8
  284. package/widgets/index.d.ts.map +0 -1
  285. package/widgets/index.js +0 -910
  286. package/widgets/progress.d.ts +0 -133
  287. package/widgets/progress.d.ts.map +0 -1
  288. package/widgets/resource.d.ts +0 -163
  289. package/widgets/resource.d.ts.map +0 -1
  290. /package/esm/components/{index.js → index.mjs} +0 -0
  291. /package/esm/render/{index.js → index.mjs} +0 -0
  292. /package/esm/web-components/{index.js → index.mjs} +0 -0
@@ -1,284 +0,0 @@
1
- /**
2
- * @file tools.tsx
3
- * @description React hooks for MCP tool interactions.
4
- *
5
- * Provides hooks for calling tools, accessing tool input/output,
6
- * and managing tool execution state.
7
- *
8
- * @example
9
- * ```tsx
10
- * import { useCallTool, useToolInput, useToolOutput } from '@frontmcp/ui/react';
11
- *
12
- * function WeatherWidget() {
13
- * const input = useToolInput<{ location: string }>();
14
- * const output = useToolOutput<WeatherData>();
15
- * const [callWeather, { data, loading, error }] = useCallTool<WeatherData>('get_weather');
16
- *
17
- * return (
18
- * <div>
19
- * <p>Location: {input?.location}</p>
20
- * <button onClick={() => callWeather({ location: 'NYC' })}>
21
- * Get Weather
22
- * </button>
23
- * {loading && <p>Loading...</p>}
24
- * {data && <p>Temperature: {data.temperature}</p>}
25
- * </div>
26
- * );
27
- * }
28
- * ```
29
- *
30
- * @module @frontmcp/ui/react/hooks
31
- */
32
- /**
33
- * State for tool execution.
34
- */
35
- export interface ToolState<T = unknown> {
36
- /** Tool result data */
37
- data: T | null;
38
- /** Whether the tool is currently executing */
39
- loading: boolean;
40
- /** Execution error, if any */
41
- error: Error | null;
42
- /** Whether the tool has been called at least once */
43
- called: boolean;
44
- }
45
- /**
46
- * Options for useCallTool hook.
47
- */
48
- export interface UseCallToolOptions {
49
- /** Automatically reset state when tool name changes */
50
- resetOnToolChange?: boolean;
51
- /** Callback when tool execution succeeds */
52
- onSuccess?: (data: unknown) => void;
53
- /** Callback when tool execution fails */
54
- onError?: (error: Error) => void;
55
- }
56
- /**
57
- * Return type for useCallTool hook.
58
- */
59
- export type UseCallToolReturn<TInput extends object, TOutput> = [
60
- /** Function to call the tool */
61
- (args: TInput) => Promise<TOutput | null>,
62
- /** Current tool state */
63
- ToolState<TOutput>,
64
- /** Reset state to initial values */
65
- () => void
66
- ];
67
- /**
68
- * Hook to get the current tool input arguments.
69
- * Returns the arguments passed to the tool when it was invoked.
70
- *
71
- * @typeParam T - Expected shape of the tool input
72
- *
73
- * @example
74
- * ```tsx
75
- * interface WeatherInput {
76
- * location: string;
77
- * units?: 'celsius' | 'fahrenheit';
78
- * }
79
- *
80
- * function WeatherWidget() {
81
- * const input = useToolInput<WeatherInput>();
82
- *
83
- * return (
84
- * <div>
85
- * <h1>Weather for {input?.location}</h1>
86
- * <p>Units: {input?.units ?? 'celsius'}</p>
87
- * </div>
88
- * );
89
- * }
90
- * ```
91
- */
92
- export declare function useToolInput<T extends object = Record<string, unknown>>(): T | null;
93
- /**
94
- * Hook to get the current tool output/result.
95
- * Returns the result data from the tool execution.
96
- *
97
- * @typeParam T - Expected shape of the tool output
98
- *
99
- * @example
100
- * ```tsx
101
- * interface WeatherOutput {
102
- * temperature: number;
103
- * condition: string;
104
- * humidity: number;
105
- * }
106
- *
107
- * function WeatherDisplay() {
108
- * const output = useToolOutput<WeatherOutput>();
109
- *
110
- * if (!output) return <div>No data</div>;
111
- *
112
- * return (
113
- * <div>
114
- * <p>Temperature: {output.temperature}°</p>
115
- * <p>Condition: {output.condition}</p>
116
- * </div>
117
- * );
118
- * }
119
- * ```
120
- */
121
- export declare function useToolOutput<T = unknown>(): T | null;
122
- /**
123
- * Hook to get the structured content from the tool output.
124
- * This is the parsed/structured version of the tool result.
125
- *
126
- * @typeParam T - Expected shape of the structured content
127
- *
128
- * @example
129
- * ```tsx
130
- * interface WeatherData {
131
- * forecast: Array<{ day: string; temp: number }>;
132
- * }
133
- *
134
- * function ForecastDisplay() {
135
- * const content = useStructuredContent<WeatherData>();
136
- *
137
- * return (
138
- * <ul>
139
- * {content?.forecast.map(day => (
140
- * <li key={day.day}>{day.day}: {day.temp}°</li>
141
- * ))}
142
- * </ul>
143
- * );
144
- * }
145
- * ```
146
- */
147
- export declare function useStructuredContent<T = unknown>(): T | null;
148
- /**
149
- * Hook to call an MCP tool with loading and error state management.
150
- *
151
- * Returns a tuple with:
152
- * 1. The call function
153
- * 2. State object (data, loading, error, called)
154
- * 3. Reset function
155
- *
156
- * @typeParam TInput - Shape of the tool input arguments
157
- * @typeParam TOutput - Expected shape of the tool output
158
- *
159
- * @example Basic usage
160
- * ```tsx
161
- * function WeatherButton() {
162
- * const [getWeather, { data, loading, error }] = useCallTool<
163
- * { location: string },
164
- * { temperature: number; condition: string }
165
- * >('get_weather');
166
- *
167
- * return (
168
- * <div>
169
- * <button
170
- * onClick={() => getWeather({ location: 'San Francisco' })}
171
- * disabled={loading}
172
- * >
173
- * {loading ? 'Loading...' : 'Get Weather'}
174
- * </button>
175
- * {error && <p className="error">{error.message}</p>}
176
- * {data && <p>{data.temperature}° - {data.condition}</p>}
177
- * </div>
178
- * );
179
- * }
180
- * ```
181
- *
182
- * @example With callbacks
183
- * ```tsx
184
- * function WeatherWidget() {
185
- * const [getWeather, state, reset] = useCallTool('get_weather', {
186
- * onSuccess: (data) => console.log('Got weather:', data),
187
- * onError: (err) => console.error('Failed:', err),
188
- * });
189
- *
190
- * return (
191
- * <div>
192
- * <button onClick={() => getWeather({ location: 'NYC' })}>
193
- * Get Weather
194
- * </button>
195
- * <button onClick={reset}>Reset</button>
196
- * </div>
197
- * );
198
- * }
199
- * ```
200
- */
201
- export declare function useCallTool<TInput extends object = Record<string, unknown>, TOutput = unknown>(toolName: string, options?: UseCallToolOptions): UseCallToolReturn<TInput, TOutput>;
202
- /**
203
- * Hook to manage multiple tool calls.
204
- * Useful when you need to track state for multiple tools.
205
- *
206
- * @example
207
- * ```tsx
208
- * function MultiToolWidget() {
209
- * const tools = useToolCalls({
210
- * weather: 'get_weather',
211
- * news: 'get_news',
212
- * stocks: 'get_stocks',
213
- * });
214
- *
215
- * return (
216
- * <div>
217
- * <button onClick={() => tools.weather.call({ location: 'NYC' })}>
218
- * Get Weather
219
- * </button>
220
- * <button onClick={() => tools.news.call({ topic: 'tech' })}>
221
- * Get News
222
- * </button>
223
- * {tools.weather.loading && <p>Loading weather...</p>}
224
- * {tools.news.data && <p>News: {tools.news.data.headline}</p>}
225
- * </div>
226
- * );
227
- * }
228
- * ```
229
- */
230
- export declare function useToolCalls<T extends Record<string, string>>(toolMap: T): {
231
- [K in keyof T]: {
232
- call: (args: Record<string, unknown>) => Promise<unknown>;
233
- data: unknown;
234
- loading: boolean;
235
- error: Error | null;
236
- reset: () => void;
237
- };
238
- };
239
- /**
240
- * Hook to send a message to the conversation.
241
- * Returns a function and state for sending messages.
242
- *
243
- * @example
244
- * ```tsx
245
- * function ChatWidget() {
246
- * const [sendMessage, { loading, error, sent }] = useSendMessage();
247
- *
248
- * return (
249
- * <button
250
- * onClick={() => sendMessage('Here is the weather update!')}
251
- * disabled={loading}
252
- * >
253
- * {loading ? 'Sending...' : 'Send Update'}
254
- * </button>
255
- * );
256
- * }
257
- * ```
258
- */
259
- export declare function useSendMessage(): [
260
- (content: string) => Promise<void>,
261
- {
262
- loading: boolean;
263
- error: Error | null;
264
- sent: boolean;
265
- }
266
- ];
267
- /**
268
- * Hook to open external links via the bridge.
269
- *
270
- * @example
271
- * ```tsx
272
- * function LinkButton() {
273
- * const openLink = useOpenLink();
274
- *
275
- * return (
276
- * <button onClick={() => openLink('https://example.com')}>
277
- * Open Website
278
- * </button>
279
- * );
280
- * }
281
- * ```
282
- */
283
- export declare function useOpenLink(): (url: string) => Promise<void>;
284
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/tools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AASH;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,uBAAuB;IACvB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,qDAAqD;IACrD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,IAAI;IAC9D,gCAAgC;IAChC,CAAC,IAAI,EAAE,MAAM,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AAI,CAAC;KACnB;CACF,CAuFA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI;IAChC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;IAClC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;CACzD,CA6BA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAc5D"}
@@ -1,80 +0,0 @@
1
- /**
2
- * @file index.ts
3
- * @description React components and hooks for FrontMCP UI.
4
- *
5
- * These are pure React components that can be used:
6
- * 1. As regular React components in your app
7
- * 2. To generate static HTML via render functions
8
- * 3. With hooks to access the MCP bridge
9
- *
10
- * @example React usage
11
- * ```tsx
12
- * import { Card, Badge, Button, Alert } from '@frontmcp/ui/react';
13
- *
14
- * function App() {
15
- * return (
16
- * <Card title="Welcome" variant="elevated">
17
- * <Badge variant="success">New</Badge>
18
- * <p>Card content here</p>
19
- * <Button variant="primary">Click Me</Button>
20
- * </Card>
21
- * );
22
- * }
23
- * ```
24
- *
25
- * @example Static HTML generation
26
- * ```typescript
27
- * import { renderCard, renderBadge } from '@frontmcp/ui/react';
28
- *
29
- * const cardHtml = await renderCard({
30
- * title: 'Welcome',
31
- * variant: 'elevated',
32
- * children: '<p>Content</p>',
33
- * });
34
- * ```
35
- *
36
- * @example Using hooks with the MCP bridge
37
- * ```tsx
38
- * import {
39
- * McpBridgeProvider,
40
- * useMcpBridge,
41
- * useToolInput,
42
- * useCallTool,
43
- * useTheme,
44
- * } from '@frontmcp/ui/react';
45
- *
46
- * function App() {
47
- * return (
48
- * <McpBridgeProvider>
49
- * <WeatherWidget />
50
- * </McpBridgeProvider>
51
- * );
52
- * }
53
- *
54
- * function WeatherWidget() {
55
- * const input = useToolInput<{ location: string }>();
56
- * const theme = useTheme();
57
- * const [getWeather, { data, loading }] = useCallTool('get_weather');
58
- *
59
- * return (
60
- * <Card title={`Weather for ${input?.location}`} variant={theme === 'dark' ? 'elevated' : 'default'}>
61
- * {loading ? 'Loading...' : data?.temperature}
62
- * </Card>
63
- * );
64
- * }
65
- * ```
66
- *
67
- * @module @frontmcp/ui/react
68
- */
69
- export { Card, renderCard, renderCardSync } from './Card';
70
- export { Badge, renderBadge, renderBadgeSync } from './Badge';
71
- export { Button, renderButton, renderButtonSync } from './Button';
72
- export { Alert, renderAlert, renderAlertSync } from './Alert';
73
- export { McpBridgeProvider, useMcpBridgeContext, useMcpBridge, useTheme, useDisplayMode, useHostContext, useCapability, useToolInput, useToolOutput, useStructuredContent, useCallTool, useToolCalls, useSendMessage, useOpenLink, type McpBridgeContextValue, type McpBridgeProviderProps, type ToolState, type UseCallToolOptions, type UseCallToolReturn, } from './hooks';
74
- export type { CardProps, CardRenderProps } from './Card';
75
- export type { BadgeProps, BadgeRenderProps } from './Badge';
76
- export type { ButtonProps, ButtonRenderProps } from './Button';
77
- export type { AlertProps, AlertRenderProps } from './Alert';
78
- export type { FmcpCard, FmcpBadge, FmcpButton, FmcpAlert, FmcpInput, FmcpSelect } from './types';
79
- export { renderChildrenToString, isBrowser, isServer } from './utils';
80
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAGH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAA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