@frontmcp/ui 0.5.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.
Files changed (393) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +438 -0
  3. package/package.json +147 -0
  4. package/src/adapters/index.d.ts +10 -0
  5. package/src/adapters/index.js +18 -0
  6. package/src/adapters/index.js.map +1 -0
  7. package/src/adapters/platform-meta.d.ts +165 -0
  8. package/src/adapters/platform-meta.js +310 -0
  9. package/src/adapters/platform-meta.js.map +1 -0
  10. package/src/base-template/bridge.d.ts +89 -0
  11. package/src/base-template/bridge.js +452 -0
  12. package/src/base-template/bridge.js.map +1 -0
  13. package/src/base-template/default-base-template.d.ts +91 -0
  14. package/src/base-template/default-base-template.js +435 -0
  15. package/src/base-template/default-base-template.js.map +1 -0
  16. package/src/base-template/index.d.ts +14 -0
  17. package/src/base-template/index.js +30 -0
  18. package/src/base-template/index.js.map +1 -0
  19. package/src/base-template/polyfills.d.ts +30 -0
  20. package/src/base-template/polyfills.js +190 -0
  21. package/src/base-template/polyfills.js.map +1 -0
  22. package/src/base-template/theme-styles.d.ts +73 -0
  23. package/src/base-template/theme-styles.js +95 -0
  24. package/src/base-template/theme-styles.js.map +1 -0
  25. package/src/bridge/adapters/base-adapter.d.ts +103 -0
  26. package/src/bridge/adapters/base-adapter.js +314 -0
  27. package/src/bridge/adapters/base-adapter.js.map +1 -0
  28. package/src/bridge/adapters/claude.adapter.d.ts +66 -0
  29. package/src/bridge/adapters/claude.adapter.js +145 -0
  30. package/src/bridge/adapters/claude.adapter.js.map +1 -0
  31. package/src/bridge/adapters/ext-apps.adapter.d.ts +142 -0
  32. package/src/bridge/adapters/ext-apps.adapter.js +416 -0
  33. package/src/bridge/adapters/ext-apps.adapter.js.map +1 -0
  34. package/src/bridge/adapters/gemini.adapter.d.ts +63 -0
  35. package/src/bridge/adapters/gemini.adapter.js +160 -0
  36. package/src/bridge/adapters/gemini.adapter.js.map +1 -0
  37. package/src/bridge/adapters/generic.adapter.d.ts +55 -0
  38. package/src/bridge/adapters/generic.adapter.js +108 -0
  39. package/src/bridge/adapters/generic.adapter.js.map +1 -0
  40. package/src/bridge/adapters/index.d.ts +25 -0
  41. package/src/bridge/adapters/index.js +65 -0
  42. package/src/bridge/adapters/index.js.map +1 -0
  43. package/src/bridge/adapters/openai.adapter.d.ts +64 -0
  44. package/src/bridge/adapters/openai.adapter.js +194 -0
  45. package/src/bridge/adapters/openai.adapter.js.map +1 -0
  46. package/src/bridge/core/adapter-registry.d.ts +121 -0
  47. package/src/bridge/core/adapter-registry.js +271 -0
  48. package/src/bridge/core/adapter-registry.js.map +1 -0
  49. package/src/bridge/core/bridge-factory.d.ts +198 -0
  50. package/src/bridge/core/bridge-factory.js +428 -0
  51. package/src/bridge/core/bridge-factory.js.map +1 -0
  52. package/src/bridge/core/index.d.ts +9 -0
  53. package/src/bridge/core/index.js +22 -0
  54. package/src/bridge/core/index.js.map +1 -0
  55. package/src/bridge/index.d.ts +61 -0
  56. package/src/bridge/index.js +94 -0
  57. package/src/bridge/index.js.map +1 -0
  58. package/src/bridge/runtime/iife-generator.d.ts +61 -0
  59. package/src/bridge/runtime/iife-generator.js +940 -0
  60. package/src/bridge/runtime/iife-generator.js.map +1 -0
  61. package/src/bridge/runtime/index.d.ts +8 -0
  62. package/src/bridge/runtime/index.js +16 -0
  63. package/src/bridge/runtime/index.js.map +1 -0
  64. package/src/bridge/types.d.ts +385 -0
  65. package/src/bridge/types.js +11 -0
  66. package/src/bridge/types.js.map +1 -0
  67. package/src/build/cdn-resources.d.ts +140 -0
  68. package/src/build/cdn-resources.js +314 -0
  69. package/src/build/cdn-resources.js.map +1 -0
  70. package/src/build/index.d.ts +294 -0
  71. package/src/build/index.js +325 -0
  72. package/src/build/index.js.map +1 -0
  73. package/src/build/widget-manifest.d.ts +212 -0
  74. package/src/build/widget-manifest.js +652 -0
  75. package/src/build/widget-manifest.js.map +1 -0
  76. package/src/bundler/bundler.d.ts +110 -0
  77. package/src/bundler/bundler.js +432 -0
  78. package/src/bundler/bundler.js.map +1 -0
  79. package/src/bundler/cache.d.ts +172 -0
  80. package/src/bundler/cache.js +250 -0
  81. package/src/bundler/cache.js.map +1 -0
  82. package/src/bundler/index.d.ts +41 -0
  83. package/src/bundler/index.js +73 -0
  84. package/src/bundler/index.js.map +1 -0
  85. package/src/bundler/sandbox/enclave-adapter.d.ts +120 -0
  86. package/src/bundler/sandbox/enclave-adapter.js +339 -0
  87. package/src/bundler/sandbox/enclave-adapter.js.map +1 -0
  88. package/src/bundler/sandbox/executor.d.ts +13 -0
  89. package/src/bundler/sandbox/executor.js +22 -0
  90. package/src/bundler/sandbox/executor.js.map +1 -0
  91. package/src/bundler/sandbox/policy.d.ts +61 -0
  92. package/src/bundler/sandbox/policy.js +238 -0
  93. package/src/bundler/sandbox/policy.js.map +1 -0
  94. package/src/bundler/types.d.ts +347 -0
  95. package/src/bundler/types.js +132 -0
  96. package/src/bundler/types.js.map +1 -0
  97. package/src/components/alert.d.ts +71 -0
  98. package/src/components/alert.js +189 -0
  99. package/src/components/alert.js.map +1 -0
  100. package/src/components/alert.schema.d.ts +114 -0
  101. package/src/components/alert.schema.js +105 -0
  102. package/src/components/alert.schema.js.map +1 -0
  103. package/src/components/avatar.d.ts +76 -0
  104. package/src/components/avatar.js +176 -0
  105. package/src/components/avatar.js.map +1 -0
  106. package/src/components/avatar.schema.d.ts +169 -0
  107. package/src/components/avatar.schema.js +103 -0
  108. package/src/components/avatar.schema.js.map +1 -0
  109. package/src/components/badge.d.ts +70 -0
  110. package/src/components/badge.js +149 -0
  111. package/src/components/badge.js.map +1 -0
  112. package/src/components/badge.schema.d.ts +109 -0
  113. package/src/components/badge.schema.js +96 -0
  114. package/src/components/badge.schema.js.map +1 -0
  115. package/src/components/button.d.ts +111 -0
  116. package/src/components/button.js +336 -0
  117. package/src/components/button.js.map +1 -0
  118. package/src/components/button.schema.d.ts +148 -0
  119. package/src/components/button.schema.js +121 -0
  120. package/src/components/button.schema.js.map +1 -0
  121. package/src/components/card.d.ts +60 -0
  122. package/src/components/card.js +117 -0
  123. package/src/components/card.js.map +1 -0
  124. package/src/components/card.schema.d.ts +113 -0
  125. package/src/components/card.schema.js +98 -0
  126. package/src/components/card.schema.js.map +1 -0
  127. package/src/components/form.d.ts +239 -0
  128. package/src/components/form.js +420 -0
  129. package/src/components/form.js.map +1 -0
  130. package/src/components/form.schema.d.ts +441 -0
  131. package/src/components/form.schema.js +406 -0
  132. package/src/components/form.schema.js.map +1 -0
  133. package/src/components/index.d.ts +29 -0
  134. package/src/components/index.js +98 -0
  135. package/src/components/index.js.map +1 -0
  136. package/src/components/list.d.ts +127 -0
  137. package/src/components/list.js +279 -0
  138. package/src/components/list.js.map +1 -0
  139. package/src/components/list.schema.d.ts +134 -0
  140. package/src/components/list.schema.js +168 -0
  141. package/src/components/list.schema.js.map +1 -0
  142. package/src/components/modal.d.ts +111 -0
  143. package/src/components/modal.js +260 -0
  144. package/src/components/modal.js.map +1 -0
  145. package/src/components/modal.schema.d.ts +186 -0
  146. package/src/components/modal.schema.js +167 -0
  147. package/src/components/modal.schema.js.map +1 -0
  148. package/src/components/table.d.ts +105 -0
  149. package/src/components/table.js +283 -0
  150. package/src/components/table.js.map +1 -0
  151. package/src/components/table.schema.d.ts +159 -0
  152. package/src/components/table.schema.js +173 -0
  153. package/src/components/table.schema.js.map +1 -0
  154. package/src/handlebars/helpers.d.ts +348 -0
  155. package/src/handlebars/helpers.js +605 -0
  156. package/src/handlebars/helpers.js.map +1 -0
  157. package/src/handlebars/index.d.ts +193 -0
  158. package/src/handlebars/index.js +350 -0
  159. package/src/handlebars/index.js.map +1 -0
  160. package/src/index.d.ts +50 -0
  161. package/src/index.js +192 -0
  162. package/src/index.js.map +1 -0
  163. package/src/layouts/base.d.ts +88 -0
  164. package/src/layouts/base.js +227 -0
  165. package/src/layouts/base.js.map +1 -0
  166. package/src/layouts/index.d.ts +7 -0
  167. package/src/layouts/index.js +25 -0
  168. package/src/layouts/index.js.map +1 -0
  169. package/src/layouts/presets.d.ts +133 -0
  170. package/src/layouts/presets.js +277 -0
  171. package/src/layouts/presets.js.map +1 -0
  172. package/src/pages/consent.d.ts +116 -0
  173. package/src/pages/consent.js +218 -0
  174. package/src/pages/consent.js.map +1 -0
  175. package/src/pages/error.d.ts +100 -0
  176. package/src/pages/error.js +263 -0
  177. package/src/pages/error.js.map +1 -0
  178. package/src/pages/index.d.ts +8 -0
  179. package/src/pages/index.js +27 -0
  180. package/src/pages/index.js.map +1 -0
  181. package/src/react/Alert.d.ts +101 -0
  182. package/src/react/Alert.js +51 -0
  183. package/src/react/Alert.js.map +1 -0
  184. package/src/react/Badge.d.ts +100 -0
  185. package/src/react/Badge.js +55 -0
  186. package/src/react/Badge.js.map +1 -0
  187. package/src/react/Button.d.ts +108 -0
  188. package/src/react/Button.js +52 -0
  189. package/src/react/Button.js.map +1 -0
  190. package/src/react/Card.d.ts +103 -0
  191. package/src/react/Card.js +55 -0
  192. package/src/react/Card.js.map +1 -0
  193. package/src/react/hooks/context.d.ts +178 -0
  194. package/src/react/hooks/context.js +287 -0
  195. package/src/react/hooks/context.js.map +1 -0
  196. package/src/react/hooks/index.d.ts +41 -0
  197. package/src/react/hooks/index.js +61 -0
  198. package/src/react/hooks/index.js.map +1 -0
  199. package/src/react/hooks/tools.d.ts +283 -0
  200. package/src/react/hooks/tools.js +465 -0
  201. package/src/react/hooks/tools.js.map +1 -0
  202. package/src/react/index.d.ts +80 -0
  203. package/src/react/index.js +113 -0
  204. package/src/react/index.js.map +1 -0
  205. package/src/react/types.d.ts +105 -0
  206. package/src/react/types.js +12 -0
  207. package/src/react/types.js.map +1 -0
  208. package/src/react/utils.d.ts +42 -0
  209. package/src/react/utils.js +99 -0
  210. package/src/react/utils.js.map +1 -0
  211. package/src/registry/index.d.ts +45 -0
  212. package/src/registry/index.js +67 -0
  213. package/src/registry/index.js.map +1 -0
  214. package/src/registry/render-template.d.ts +86 -0
  215. package/src/registry/render-template.js +239 -0
  216. package/src/registry/render-template.js.map +1 -0
  217. package/src/registry/tool-ui.registry.d.ts +260 -0
  218. package/src/registry/tool-ui.registry.js +438 -0
  219. package/src/registry/tool-ui.registry.js.map +1 -0
  220. package/src/registry/uri-utils.d.ts +55 -0
  221. package/src/registry/uri-utils.js +97 -0
  222. package/src/registry/uri-utils.js.map +1 -0
  223. package/src/render/index.d.ts +7 -0
  224. package/src/render/index.js +14 -0
  225. package/src/render/index.js.map +1 -0
  226. package/src/render/prerender.d.ts +56 -0
  227. package/src/render/prerender.js +98 -0
  228. package/src/render/prerender.js.map +1 -0
  229. package/src/renderers/cache.d.ts +144 -0
  230. package/src/renderers/cache.js +240 -0
  231. package/src/renderers/cache.js.map +1 -0
  232. package/src/renderers/html.renderer.d.ts +122 -0
  233. package/src/renderers/html.renderer.js +204 -0
  234. package/src/renderers/html.renderer.js.map +1 -0
  235. package/src/renderers/index.d.ts +35 -0
  236. package/src/renderers/index.js +70 -0
  237. package/src/renderers/index.js.map +1 -0
  238. package/src/renderers/mdx.renderer.d.ts +119 -0
  239. package/src/renderers/mdx.renderer.js +305 -0
  240. package/src/renderers/mdx.renderer.js.map +1 -0
  241. package/src/renderers/react.renderer.d.ts +95 -0
  242. package/src/renderers/react.renderer.js +260 -0
  243. package/src/renderers/react.renderer.js.map +1 -0
  244. package/src/renderers/registry.d.ts +133 -0
  245. package/src/renderers/registry.js +232 -0
  246. package/src/renderers/registry.js.map +1 -0
  247. package/src/renderers/types.d.ts +341 -0
  248. package/src/renderers/types.js +9 -0
  249. package/src/renderers/types.js.map +1 -0
  250. package/src/renderers/utils/detect.d.ts +106 -0
  251. package/src/renderers/utils/detect.js +267 -0
  252. package/src/renderers/utils/detect.js.map +1 -0
  253. package/src/renderers/utils/hash.d.ts +39 -0
  254. package/src/renderers/utils/hash.js +75 -0
  255. package/src/renderers/utils/hash.js.map +1 -0
  256. package/src/renderers/utils/index.d.ts +8 -0
  257. package/src/renderers/utils/index.js +28 -0
  258. package/src/renderers/utils/index.js.map +1 -0
  259. package/src/renderers/utils/transpiler.d.ts +88 -0
  260. package/src/renderers/utils/transpiler.js +215 -0
  261. package/src/renderers/utils/transpiler.js.map +1 -0
  262. package/src/runtime/adapters/html.adapter.d.ts +58 -0
  263. package/src/runtime/adapters/html.adapter.js +131 -0
  264. package/src/runtime/adapters/html.adapter.js.map +1 -0
  265. package/src/runtime/adapters/index.d.ts +25 -0
  266. package/src/runtime/adapters/index.js +54 -0
  267. package/src/runtime/adapters/index.js.map +1 -0
  268. package/src/runtime/adapters/mdx.adapter.d.ts +72 -0
  269. package/src/runtime/adapters/mdx.adapter.js +241 -0
  270. package/src/runtime/adapters/mdx.adapter.js.map +1 -0
  271. package/src/runtime/adapters/react.adapter.d.ts +69 -0
  272. package/src/runtime/adapters/react.adapter.js +245 -0
  273. package/src/runtime/adapters/react.adapter.js.map +1 -0
  274. package/src/runtime/adapters/types.d.ts +94 -0
  275. package/src/runtime/adapters/types.js +11 -0
  276. package/src/runtime/adapters/types.js.map +1 -0
  277. package/src/runtime/csp.d.ts +37 -0
  278. package/src/runtime/csp.js +140 -0
  279. package/src/runtime/csp.js.map +1 -0
  280. package/src/runtime/index.d.ts +16 -0
  281. package/src/runtime/index.js +72 -0
  282. package/src/runtime/index.js.map +1 -0
  283. package/src/runtime/mcp-bridge.d.ts +100 -0
  284. package/src/runtime/mcp-bridge.js +581 -0
  285. package/src/runtime/mcp-bridge.js.map +1 -0
  286. package/src/runtime/renderer-runtime.d.ts +132 -0
  287. package/src/runtime/renderer-runtime.js +389 -0
  288. package/src/runtime/renderer-runtime.js.map +1 -0
  289. package/src/runtime/sanitizer.d.ts +171 -0
  290. package/src/runtime/sanitizer.js +318 -0
  291. package/src/runtime/sanitizer.js.map +1 -0
  292. package/src/runtime/types.d.ts +414 -0
  293. package/src/runtime/types.js +12 -0
  294. package/src/runtime/types.js.map +1 -0
  295. package/src/runtime/wrapper.d.ts +375 -0
  296. package/src/runtime/wrapper.js +1793 -0
  297. package/src/runtime/wrapper.js.map +1 -0
  298. package/src/styles/index.d.ts +7 -0
  299. package/src/styles/index.js +11 -0
  300. package/src/styles/index.js.map +1 -0
  301. package/src/styles/variants.d.ts +50 -0
  302. package/src/styles/variants.js +175 -0
  303. package/src/styles/variants.js.map +1 -0
  304. package/src/theme/cdn.d.ts +194 -0
  305. package/src/theme/cdn.js +375 -0
  306. package/src/theme/cdn.js.map +1 -0
  307. package/src/theme/index.d.ts +17 -0
  308. package/src/theme/index.js +57 -0
  309. package/src/theme/index.js.map +1 -0
  310. package/src/theme/platforms.d.ts +106 -0
  311. package/src/theme/platforms.js +161 -0
  312. package/src/theme/platforms.js.map +1 -0
  313. package/src/theme/presets/github-openai.d.ts +49 -0
  314. package/src/theme/presets/github-openai.js +189 -0
  315. package/src/theme/presets/github-openai.js.map +1 -0
  316. package/src/theme/presets/index.d.ts +10 -0
  317. package/src/theme/presets/index.js +17 -0
  318. package/src/theme/presets/index.js.map +1 -0
  319. package/src/theme/theme.d.ts +395 -0
  320. package/src/theme/theme.js +332 -0
  321. package/src/theme/theme.js.map +1 -0
  322. package/src/tool-template/builder.d.ts +212 -0
  323. package/src/tool-template/builder.js +397 -0
  324. package/src/tool-template/builder.js.map +1 -0
  325. package/src/tool-template/index.d.ts +15 -0
  326. package/src/tool-template/index.js +38 -0
  327. package/src/tool-template/index.js.map +1 -0
  328. package/src/types/index.d.ts +13 -0
  329. package/src/types/index.js +26 -0
  330. package/src/types/index.js.map +1 -0
  331. package/src/types/ui-config.d.ts +357 -0
  332. package/src/types/ui-config.js +12 -0
  333. package/src/types/ui-config.js.map +1 -0
  334. package/src/types/ui-runtime.d.ts +965 -0
  335. package/src/types/ui-runtime.js +117 -0
  336. package/src/types/ui-runtime.js.map +1 -0
  337. package/src/validation/error-box.d.ts +55 -0
  338. package/src/validation/error-box.js +75 -0
  339. package/src/validation/error-box.js.map +1 -0
  340. package/src/validation/index.d.ts +12 -0
  341. package/src/validation/index.js +21 -0
  342. package/src/validation/index.js.map +1 -0
  343. package/src/validation/wrapper.d.ts +96 -0
  344. package/src/validation/wrapper.js +117 -0
  345. package/src/validation/wrapper.js.map +1 -0
  346. package/src/web-components/core/attribute-parser.d.ts +85 -0
  347. package/src/web-components/core/attribute-parser.js +189 -0
  348. package/src/web-components/core/attribute-parser.js.map +1 -0
  349. package/src/web-components/core/base-element.d.ts +197 -0
  350. package/src/web-components/core/base-element.js +289 -0
  351. package/src/web-components/core/base-element.js.map +1 -0
  352. package/src/web-components/core/index.d.ts +8 -0
  353. package/src/web-components/core/index.js +18 -0
  354. package/src/web-components/core/index.js.map +1 -0
  355. package/src/web-components/elements/fmcp-alert.d.ts +45 -0
  356. package/src/web-components/elements/fmcp-alert.js +93 -0
  357. package/src/web-components/elements/fmcp-alert.js.map +1 -0
  358. package/src/web-components/elements/fmcp-badge.d.ts +46 -0
  359. package/src/web-components/elements/fmcp-badge.js +99 -0
  360. package/src/web-components/elements/fmcp-badge.js.map +1 -0
  361. package/src/web-components/elements/fmcp-button.d.ts +124 -0
  362. package/src/web-components/elements/fmcp-button.js +233 -0
  363. package/src/web-components/elements/fmcp-button.js.map +1 -0
  364. package/src/web-components/elements/fmcp-card.d.ts +52 -0
  365. package/src/web-components/elements/fmcp-card.js +115 -0
  366. package/src/web-components/elements/fmcp-card.js.map +1 -0
  367. package/src/web-components/elements/fmcp-input.d.ts +95 -0
  368. package/src/web-components/elements/fmcp-input.js +248 -0
  369. package/src/web-components/elements/fmcp-input.js.map +1 -0
  370. package/src/web-components/elements/fmcp-select.d.ts +99 -0
  371. package/src/web-components/elements/fmcp-select.js +243 -0
  372. package/src/web-components/elements/fmcp-select.js.map +1 -0
  373. package/src/web-components/elements/index.d.ts +12 -0
  374. package/src/web-components/elements/index.js +34 -0
  375. package/src/web-components/elements/index.js.map +1 -0
  376. package/src/web-components/index.d.ts +49 -0
  377. package/src/web-components/index.js +75 -0
  378. package/src/web-components/index.js.map +1 -0
  379. package/src/web-components/register.d.ts +56 -0
  380. package/src/web-components/register.js +80 -0
  381. package/src/web-components/register.js.map +1 -0
  382. package/src/web-components/types.d.ts +121 -0
  383. package/src/web-components/types.js +25 -0
  384. package/src/web-components/types.js.map +1 -0
  385. package/src/widgets/index.d.ts +7 -0
  386. package/src/widgets/index.js +24 -0
  387. package/src/widgets/index.js.map +1 -0
  388. package/src/widgets/progress.d.ts +132 -0
  389. package/src/widgets/progress.js +303 -0
  390. package/src/widgets/progress.js.map +1 -0
  391. package/src/widgets/resource.d.ts +162 -0
  392. package/src/widgets/resource.js +340 -0
  393. package/src/widgets/resource.js.map +1 -0
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * @file index.ts
4
+ * @description React components and hooks for FrontMCP UI.
5
+ *
6
+ * These are pure React components that can be used:
7
+ * 1. As regular React components in your app
8
+ * 2. To generate static HTML via render functions
9
+ * 3. With hooks to access the MCP bridge
10
+ *
11
+ * @example React usage
12
+ * ```tsx
13
+ * import { Card, Badge, Button, Alert } from '@frontmcp/ui/react';
14
+ *
15
+ * function App() {
16
+ * return (
17
+ * <Card title="Welcome" variant="elevated">
18
+ * <Badge variant="success">New</Badge>
19
+ * <p>Card content here</p>
20
+ * <Button variant="primary">Click Me</Button>
21
+ * </Card>
22
+ * );
23
+ * }
24
+ * ```
25
+ *
26
+ * @example Static HTML generation
27
+ * ```typescript
28
+ * import { renderCard, renderBadge } from '@frontmcp/ui/react';
29
+ *
30
+ * const cardHtml = await renderCard({
31
+ * title: 'Welcome',
32
+ * variant: 'elevated',
33
+ * children: '<p>Content</p>',
34
+ * });
35
+ * ```
36
+ *
37
+ * @example Using hooks with the MCP bridge
38
+ * ```tsx
39
+ * import {
40
+ * McpBridgeProvider,
41
+ * useMcpBridge,
42
+ * useToolInput,
43
+ * useCallTool,
44
+ * useTheme,
45
+ * } from '@frontmcp/ui/react';
46
+ *
47
+ * function App() {
48
+ * return (
49
+ * <McpBridgeProvider>
50
+ * <WeatherWidget />
51
+ * </McpBridgeProvider>
52
+ * );
53
+ * }
54
+ *
55
+ * function WeatherWidget() {
56
+ * const input = useToolInput<{ location: string }>();
57
+ * const theme = useTheme();
58
+ * const [getWeather, { data, loading }] = useCallTool('get_weather');
59
+ *
60
+ * return (
61
+ * <Card title={`Weather for ${input?.location}`} variant={theme === 'dark' ? 'elevated' : 'default'}>
62
+ * {loading ? 'Loading...' : data?.temperature}
63
+ * </Card>
64
+ * );
65
+ * }
66
+ * ```
67
+ *
68
+ * @module @frontmcp/ui/react
69
+ */
70
+ Object.defineProperty(exports, "__esModule", { value: true });
71
+ exports.isServer = exports.isBrowser = exports.renderChildrenToString = exports.useOpenLink = exports.useSendMessage = exports.useToolCalls = exports.useCallTool = exports.useStructuredContent = exports.useToolOutput = exports.useToolInput = exports.useCapability = exports.useHostContext = exports.useDisplayMode = exports.useTheme = exports.useMcpBridge = exports.useMcpBridgeContext = exports.McpBridgeProvider = exports.renderAlertSync = exports.renderAlert = exports.Alert = exports.renderButtonSync = exports.renderButton = exports.Button = exports.renderBadgeSync = exports.renderBadge = exports.Badge = exports.renderCardSync = exports.renderCard = exports.Card = void 0;
72
+ // React Components
73
+ var Card_1 = require("./Card");
74
+ Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return Card_1.Card; } });
75
+ Object.defineProperty(exports, "renderCard", { enumerable: true, get: function () { return Card_1.renderCard; } });
76
+ Object.defineProperty(exports, "renderCardSync", { enumerable: true, get: function () { return Card_1.renderCardSync; } });
77
+ var Badge_1 = require("./Badge");
78
+ Object.defineProperty(exports, "Badge", { enumerable: true, get: function () { return Badge_1.Badge; } });
79
+ Object.defineProperty(exports, "renderBadge", { enumerable: true, get: function () { return Badge_1.renderBadge; } });
80
+ Object.defineProperty(exports, "renderBadgeSync", { enumerable: true, get: function () { return Badge_1.renderBadgeSync; } });
81
+ var Button_1 = require("./Button");
82
+ Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
83
+ Object.defineProperty(exports, "renderButton", { enumerable: true, get: function () { return Button_1.renderButton; } });
84
+ Object.defineProperty(exports, "renderButtonSync", { enumerable: true, get: function () { return Button_1.renderButtonSync; } });
85
+ var Alert_1 = require("./Alert");
86
+ Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return Alert_1.Alert; } });
87
+ Object.defineProperty(exports, "renderAlert", { enumerable: true, get: function () { return Alert_1.renderAlert; } });
88
+ Object.defineProperty(exports, "renderAlertSync", { enumerable: true, get: function () { return Alert_1.renderAlertSync; } });
89
+ // React Hooks for MCP Bridge
90
+ var hooks_1 = require("./hooks");
91
+ // Provider
92
+ Object.defineProperty(exports, "McpBridgeProvider", { enumerable: true, get: function () { return hooks_1.McpBridgeProvider; } });
93
+ // Bridge hooks
94
+ Object.defineProperty(exports, "useMcpBridgeContext", { enumerable: true, get: function () { return hooks_1.useMcpBridgeContext; } });
95
+ Object.defineProperty(exports, "useMcpBridge", { enumerable: true, get: function () { return hooks_1.useMcpBridge; } });
96
+ Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return hooks_1.useTheme; } });
97
+ Object.defineProperty(exports, "useDisplayMode", { enumerable: true, get: function () { return hooks_1.useDisplayMode; } });
98
+ Object.defineProperty(exports, "useHostContext", { enumerable: true, get: function () { return hooks_1.useHostContext; } });
99
+ Object.defineProperty(exports, "useCapability", { enumerable: true, get: function () { return hooks_1.useCapability; } });
100
+ // Tool hooks
101
+ Object.defineProperty(exports, "useToolInput", { enumerable: true, get: function () { return hooks_1.useToolInput; } });
102
+ Object.defineProperty(exports, "useToolOutput", { enumerable: true, get: function () { return hooks_1.useToolOutput; } });
103
+ Object.defineProperty(exports, "useStructuredContent", { enumerable: true, get: function () { return hooks_1.useStructuredContent; } });
104
+ Object.defineProperty(exports, "useCallTool", { enumerable: true, get: function () { return hooks_1.useCallTool; } });
105
+ Object.defineProperty(exports, "useToolCalls", { enumerable: true, get: function () { return hooks_1.useToolCalls; } });
106
+ Object.defineProperty(exports, "useSendMessage", { enumerable: true, get: function () { return hooks_1.useSendMessage; } });
107
+ Object.defineProperty(exports, "useOpenLink", { enumerable: true, get: function () { return hooks_1.useOpenLink; } });
108
+ // Utilities (deprecated, use render/prerender instead)
109
+ var utils_1 = require("./utils");
110
+ Object.defineProperty(exports, "renderChildrenToString", { enumerable: true, get: function () { return utils_1.renderChildrenToString; } });
111
+ Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return utils_1.isBrowser; } });
112
+ Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return utils_1.isServer; } });
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;;;AAEH,mBAAmB;AACnB,+BAA0D;AAAjD,4FAAA,IAAI,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AACzC,iCAA8D;AAArD,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,wGAAA,eAAe,OAAA;AAC5C,mCAAkE;AAAzD,gGAAA,MAAM,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAC/C,iCAA8D;AAArD,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,wGAAA,eAAe,OAAA;AAE5C,6BAA6B;AAC7B,iCAwBiB;AAvBf,WAAW;AACX,0GAAA,iBAAiB,OAAA;AACjB,eAAe;AACf,4GAAA,mBAAmB,OAAA;AACnB,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AACR,uGAAA,cAAc,OAAA;AACd,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AACb,aAAa;AACb,qGAAA,YAAY,OAAA;AACZ,sGAAA,aAAa,OAAA;AACb,6GAAA,oBAAoB,OAAA;AACpB,oGAAA,WAAW,OAAA;AACX,qGAAA,YAAY,OAAA;AACZ,uGAAA,cAAc,OAAA;AACd,oGAAA,WAAW,OAAA;AAwBb,uDAAuD;AACvD,iCAAsE;AAA7D,+GAAA,sBAAsB,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,iGAAA,QAAQ,OAAA","sourcesContent":["/**\n * @file index.ts\n * @description React components and hooks for FrontMCP UI.\n *\n * These are pure React components that can be used:\n * 1. As regular React components in your app\n * 2. To generate static HTML via render functions\n * 3. With hooks to access the MCP bridge\n *\n * @example React usage\n * ```tsx\n * import { Card, Badge, Button, Alert } from '@frontmcp/ui/react';\n *\n * function App() {\n * return (\n * <Card title=\"Welcome\" variant=\"elevated\">\n * <Badge variant=\"success\">New</Badge>\n * <p>Card content here</p>\n * <Button variant=\"primary\">Click Me</Button>\n * </Card>\n * );\n * }\n * ```\n *\n * @example Static HTML generation\n * ```typescript\n * import { renderCard, renderBadge } from '@frontmcp/ui/react';\n *\n * const cardHtml = await renderCard({\n * title: 'Welcome',\n * variant: 'elevated',\n * children: '<p>Content</p>',\n * });\n * ```\n *\n * @example Using hooks with the MCP bridge\n * ```tsx\n * import {\n * McpBridgeProvider,\n * useMcpBridge,\n * useToolInput,\n * useCallTool,\n * useTheme,\n * } from '@frontmcp/ui/react';\n *\n * function App() {\n * return (\n * <McpBridgeProvider>\n * <WeatherWidget />\n * </McpBridgeProvider>\n * );\n * }\n *\n * function WeatherWidget() {\n * const input = useToolInput<{ location: string }>();\n * const theme = useTheme();\n * const [getWeather, { data, loading }] = useCallTool('get_weather');\n *\n * return (\n * <Card title={`Weather for ${input?.location}`} variant={theme === 'dark' ? 'elevated' : 'default'}>\n * {loading ? 'Loading...' : data?.temperature}\n * </Card>\n * );\n * }\n * ```\n *\n * @module @frontmcp/ui/react\n */\n\n// React Components\nexport { Card, renderCard, renderCardSync } from './Card';\nexport { Badge, renderBadge, renderBadgeSync } from './Badge';\nexport { Button, renderButton, renderButtonSync } from './Button';\nexport { Alert, renderAlert, renderAlertSync } from './Alert';\n\n// React Hooks for MCP Bridge\nexport {\n // Provider\n McpBridgeProvider,\n // Bridge hooks\n useMcpBridgeContext,\n useMcpBridge,\n useTheme,\n useDisplayMode,\n useHostContext,\n useCapability,\n // Tool hooks\n useToolInput,\n useToolOutput,\n useStructuredContent,\n useCallTool,\n useToolCalls,\n useSendMessage,\n useOpenLink,\n // Types\n type McpBridgeContextValue,\n type McpBridgeProviderProps,\n type ToolState,\n type UseCallToolOptions,\n type UseCallToolReturn,\n} from './hooks';\n\n// Component Types\nexport type { CardProps, CardRenderProps, CardVariant, CardSize } from './Card';\nexport type { BadgeProps, BadgeRenderProps, BadgeVariant, BadgeSize } from './Badge';\nexport type { ButtonProps, ButtonRenderProps, ButtonVariant, ButtonSize } from './Button';\nexport type { AlertProps, AlertRenderProps, AlertVariant } from './Alert';\n\n// Note: ButtonProps and AlertProps are now exported from the new .tsx files above\n// The types.ts file is deprecated\n\n// Legacy web component types (deprecated, will be removed)\nexport type { FmcpCard, FmcpBadge, FmcpButton, FmcpAlert } from './types';\n\n// Legacy schema types (deprecated, use styles/variants instead)\nexport type { CardOptions, BadgeOptions, ButtonOptions, AlertOptions } from './types';\n\n// Utilities (deprecated, use render/prerender instead)\nexport { renderChildrenToString, isBrowser, isServer } from './utils';\n"]}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description TypeScript types for React wrapper components.
4
+ *
5
+ * Re-exports element types from web-components for use with React refs,
6
+ * and defines React-specific prop interfaces.
7
+ *
8
+ * @module @frontmcp/ui/react/types
9
+ */
10
+ import type { ReactNode } from 'react';
11
+ import type { CardOptions, CardVariant, CardSize, BadgeOptions, BadgeVariant, BadgeSize, ButtonOptions, AlertOptions } from '../components';
12
+ export type { FmcpButton, FmcpCard, FmcpAlert, FmcpBadge, FmcpInput, FmcpSelect } from '../web-components';
13
+ /**
14
+ * React props for Card component
15
+ */
16
+ export interface CardProps {
17
+ /** Card title */
18
+ title?: string;
19
+ /** Card subtitle/description */
20
+ subtitle?: string;
21
+ /** Header actions content */
22
+ headerActions?: ReactNode;
23
+ /** Footer content */
24
+ footer?: ReactNode;
25
+ /** Card variant */
26
+ variant?: CardVariant;
27
+ /** Card size (padding) */
28
+ size?: CardSize;
29
+ /** Additional CSS classes */
30
+ className?: string;
31
+ /** Card ID */
32
+ id?: string;
33
+ /** Clickable card (adds hover effects) */
34
+ clickable?: boolean;
35
+ /** Click handler URL */
36
+ href?: string;
37
+ /** Card content */
38
+ children: ReactNode;
39
+ }
40
+ /**
41
+ * React props for Badge component
42
+ */
43
+ export interface BadgeProps {
44
+ /** Badge variant */
45
+ variant?: BadgeVariant;
46
+ /** Badge size */
47
+ size?: BadgeSize;
48
+ /** Rounded pill style */
49
+ pill?: boolean;
50
+ /** Icon before text (ReactNode) */
51
+ icon?: ReactNode;
52
+ /** Dot indicator (no text) */
53
+ dot?: boolean;
54
+ /** Additional CSS classes */
55
+ className?: string;
56
+ /** Removable badge */
57
+ removable?: boolean;
58
+ /** Badge content */
59
+ children?: ReactNode;
60
+ }
61
+ /**
62
+ * React props for Button component
63
+ */
64
+ export interface ButtonProps {
65
+ /** Button variant */
66
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'success';
67
+ /** Button size */
68
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
69
+ /** Disabled state */
70
+ disabled?: boolean;
71
+ /** Loading state */
72
+ loading?: boolean;
73
+ /** Full width */
74
+ fullWidth?: boolean;
75
+ /** Icon position */
76
+ iconPosition?: 'left' | 'right';
77
+ /** Icon content */
78
+ icon?: ReactNode;
79
+ /** Button type */
80
+ type?: 'button' | 'submit' | 'reset';
81
+ /** Additional CSS classes */
82
+ className?: string;
83
+ /** Click handler */
84
+ onClick?: () => void;
85
+ /** Button content */
86
+ children: ReactNode;
87
+ }
88
+ /**
89
+ * React props for Alert component
90
+ */
91
+ export interface AlertProps {
92
+ /** Alert variant */
93
+ variant?: 'info' | 'success' | 'warning' | 'danger';
94
+ /** Alert title */
95
+ title?: string;
96
+ /** Icon content */
97
+ icon?: ReactNode;
98
+ /** Dismissible */
99
+ dismissible?: boolean;
100
+ /** Additional CSS classes */
101
+ className?: string;
102
+ /** Alert content */
103
+ children: ReactNode;
104
+ }
105
+ export type { CardOptions, CardVariant, CardSize, BadgeOptions, BadgeVariant, BadgeSize, ButtonOptions, AlertOptions };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * @file types.ts
4
+ * @description TypeScript types for React wrapper components.
5
+ *
6
+ * Re-exports element types from web-components for use with React refs,
7
+ * and defines React-specific prop interfaces.
8
+ *
9
+ * @module @frontmcp/ui/react/types
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG","sourcesContent":["/**\n * @file types.ts\n * @description TypeScript types for React wrapper components.\n *\n * Re-exports element types from web-components for use with React refs,\n * and defines React-specific prop interfaces.\n *\n * @module @frontmcp/ui/react/types\n */\n\nimport type { ReactNode } from 'react';\nimport type {\n CardOptions,\n CardVariant,\n CardSize,\n BadgeOptions,\n BadgeVariant,\n BadgeSize,\n ButtonOptions,\n AlertOptions,\n} from '../components';\n\n// Re-export element classes for ref typing\nexport type { FmcpButton, FmcpCard, FmcpAlert, FmcpBadge, FmcpInput, FmcpSelect } from '../web-components';\n\n// ============================================\n// Card Props\n// ============================================\n\n/**\n * React props for Card component\n */\nexport interface CardProps {\n /** Card title */\n title?: string;\n /** Card subtitle/description */\n subtitle?: string;\n /** Header actions content */\n headerActions?: ReactNode;\n /** Footer content */\n footer?: ReactNode;\n /** Card variant */\n variant?: CardVariant;\n /** Card size (padding) */\n size?: CardSize;\n /** Additional CSS classes */\n className?: string;\n /** Card ID */\n id?: string;\n /** Clickable card (adds hover effects) */\n clickable?: boolean;\n /** Click handler URL */\n href?: string;\n /** Card content */\n children: ReactNode;\n}\n\n// ============================================\n// Badge Props\n// ============================================\n\n/**\n * React props for Badge component\n */\nexport interface BadgeProps {\n /** Badge variant */\n variant?: BadgeVariant;\n /** Badge size */\n size?: BadgeSize;\n /** Rounded pill style */\n pill?: boolean;\n /** Icon before text (ReactNode) */\n icon?: ReactNode;\n /** Dot indicator (no text) */\n dot?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Removable badge */\n removable?: boolean;\n /** Badge content */\n children?: ReactNode;\n}\n\n// ============================================\n// Button Props\n// ============================================\n\n/**\n * React props for Button component\n */\nexport interface ButtonProps {\n /** Button variant */\n variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'success';\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Disabled state */\n disabled?: boolean;\n /** Loading state */\n loading?: boolean;\n /** Full width */\n fullWidth?: boolean;\n /** Icon position */\n iconPosition?: 'left' | 'right';\n /** Icon content */\n icon?: ReactNode;\n /** Button type */\n type?: 'button' | 'submit' | 'reset';\n /** Additional CSS classes */\n className?: string;\n /** Click handler */\n onClick?: () => void;\n /** Button content */\n children: ReactNode;\n}\n\n// ============================================\n// Alert Props\n// ============================================\n\n/**\n * React props for Alert component\n */\nexport interface AlertProps {\n /** Alert variant */\n variant?: 'info' | 'success' | 'warning' | 'danger';\n /** Alert title */\n title?: string;\n /** Icon content */\n icon?: ReactNode;\n /** Dismissible */\n dismissible?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Alert content */\n children: ReactNode;\n}\n\n// ============================================\n// Re-export schema types for convenience\n// ============================================\n\nexport type { CardOptions, CardVariant, CardSize, BadgeOptions, BadgeVariant, BadgeSize, ButtonOptions, AlertOptions };\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file utils.ts
3
+ * @description Utility functions for React wrapper components.
4
+ *
5
+ * Provides helpers for converting React children to HTML strings
6
+ * for SSR compatibility with FrontMCP web components.
7
+ *
8
+ * @module @frontmcp/ui/react/utils
9
+ */
10
+ import type { ReactNode } from 'react';
11
+ /**
12
+ * Convert React children to an HTML string for SSR.
13
+ *
14
+ * - Strings are escaped via escapeHtml()
15
+ * - Numbers are converted to strings
16
+ * - ReactNode is rendered via ReactDOMServer.renderToStaticMarkup()
17
+ * - null/undefined return empty string
18
+ *
19
+ * @param children - React children to convert
20
+ * @returns HTML string representation
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // String children
25
+ * renderChildrenToString('Hello') // 'Hello' (escaped)
26
+ *
27
+ * // React element children
28
+ * renderChildrenToString(<div>Test</div>) // '<div>Test</div>'
29
+ *
30
+ * // Mixed children
31
+ * renderChildrenToString(['Hello', <span>World</span>])
32
+ * ```
33
+ */
34
+ export declare function renderChildrenToString(children: ReactNode): string;
35
+ /**
36
+ * Check if we're running in a browser environment
37
+ */
38
+ export declare function isBrowser(): boolean;
39
+ /**
40
+ * Check if we're running in a Node.js environment
41
+ */
42
+ export declare function isServer(): boolean;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * @file utils.ts
4
+ * @description Utility functions for React wrapper components.
5
+ *
6
+ * Provides helpers for converting React children to HTML strings
7
+ * for SSR compatibility with FrontMCP web components.
8
+ *
9
+ * @module @frontmcp/ui/react/utils
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.renderChildrenToString = renderChildrenToString;
13
+ exports.isBrowser = isBrowser;
14
+ exports.isServer = isServer;
15
+ const base_1 = require("../layouts/base");
16
+ // Lazy-load ReactDOMServer to avoid import errors in non-React environments
17
+ let cachedReactDOMServer = null;
18
+ /**
19
+ * Get ReactDOMServer lazily (only when needed)
20
+ */
21
+ function getReactDOMServer() {
22
+ if (!cachedReactDOMServer) {
23
+ try {
24
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
25
+ cachedReactDOMServer = require('react-dom/server');
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ return cachedReactDOMServer;
32
+ }
33
+ /**
34
+ * Convert React children to an HTML string for SSR.
35
+ *
36
+ * - Strings are escaped via escapeHtml()
37
+ * - Numbers are converted to strings
38
+ * - ReactNode is rendered via ReactDOMServer.renderToStaticMarkup()
39
+ * - null/undefined return empty string
40
+ *
41
+ * @param children - React children to convert
42
+ * @returns HTML string representation
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // String children
47
+ * renderChildrenToString('Hello') // 'Hello' (escaped)
48
+ *
49
+ * // React element children
50
+ * renderChildrenToString(<div>Test</div>) // '<div>Test</div>'
51
+ *
52
+ * // Mixed children
53
+ * renderChildrenToString(['Hello', <span>World</span>])
54
+ * ```
55
+ */
56
+ function renderChildrenToString(children) {
57
+ // Handle null/undefined
58
+ if (children == null) {
59
+ return '';
60
+ }
61
+ // Handle string - escape HTML
62
+ if (typeof children === 'string') {
63
+ return (0, base_1.escapeHtml)(children);
64
+ }
65
+ // Handle number - convert to string
66
+ if (typeof children === 'number') {
67
+ return String(children);
68
+ }
69
+ // Handle boolean - React doesn't render true/false
70
+ if (typeof children === 'boolean') {
71
+ return '';
72
+ }
73
+ // Handle React elements and arrays - use ReactDOMServer
74
+ try {
75
+ const server = getReactDOMServer();
76
+ if (server) {
77
+ return server.renderToStaticMarkup(children);
78
+ }
79
+ // Fallback for non-React environments
80
+ return String(children);
81
+ }
82
+ catch {
83
+ // Fallback for non-React environments
84
+ return String(children);
85
+ }
86
+ }
87
+ /**
88
+ * Check if we're running in a browser environment
89
+ */
90
+ function isBrowser() {
91
+ return typeof window !== 'undefined';
92
+ }
93
+ /**
94
+ * Check if we're running in a Node.js environment
95
+ */
96
+ function isServer() {
97
+ return typeof window === 'undefined';
98
+ }
99
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/react/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA8CH,wDAiCC;AAKD,8BAEC;AAKD,4BAEC;AA1FD,0CAA6C;AAE7C,4EAA4E;AAC5E,IAAI,oBAAoB,GAA6C,IAAI,CAAC;AAE1E;;GAEG;AACH,SAAS,iBAAiB;IACxB,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,iEAAiE;YACjE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,sBAAsB,CAAC,QAAmB;IACxD,wBAAwB;IACxB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,8BAA8B;IAC9B,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAA,iBAAU,EAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,oCAAoC;IACpC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,mDAAmD;IACnD,IAAI,OAAO,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,wDAAwD;IACxD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC,oBAAoB,CAAC,QAA8B,CAAC,CAAC;QACrE,CAAC;QACD,sCAAsC;QACtC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;QACtC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACvC,CAAC","sourcesContent":["/**\n * @file utils.ts\n * @description Utility functions for React wrapper components.\n *\n * Provides helpers for converting React children to HTML strings\n * for SSR compatibility with FrontMCP web components.\n *\n * @module @frontmcp/ui/react/utils\n */\n\nimport type { ReactNode } from 'react';\nimport { escapeHtml } from '../layouts/base';\n\n// Lazy-load ReactDOMServer to avoid import errors in non-React environments\nlet cachedReactDOMServer: typeof import('react-dom/server') | null = null;\n\n/**\n * Get ReactDOMServer lazily (only when needed)\n */\nfunction getReactDOMServer(): typeof import('react-dom/server') | null {\n if (!cachedReactDOMServer) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n cachedReactDOMServer = require('react-dom/server');\n } catch {\n return null;\n }\n }\n return cachedReactDOMServer;\n}\n\n/**\n * Convert React children to an HTML string for SSR.\n *\n * - Strings are escaped via escapeHtml()\n * - Numbers are converted to strings\n * - ReactNode is rendered via ReactDOMServer.renderToStaticMarkup()\n * - null/undefined return empty string\n *\n * @param children - React children to convert\n * @returns HTML string representation\n *\n * @example\n * ```tsx\n * // String children\n * renderChildrenToString('Hello') // 'Hello' (escaped)\n *\n * // React element children\n * renderChildrenToString(<div>Test</div>) // '<div>Test</div>'\n *\n * // Mixed children\n * renderChildrenToString(['Hello', <span>World</span>])\n * ```\n */\nexport function renderChildrenToString(children: ReactNode): string {\n // Handle null/undefined\n if (children == null) {\n return '';\n }\n\n // Handle string - escape HTML\n if (typeof children === 'string') {\n return escapeHtml(children);\n }\n\n // Handle number - convert to string\n if (typeof children === 'number') {\n return String(children);\n }\n\n // Handle boolean - React doesn't render true/false\n if (typeof children === 'boolean') {\n return '';\n }\n\n // Handle React elements and arrays - use ReactDOMServer\n try {\n const server = getReactDOMServer();\n if (server) {\n return server.renderToStaticMarkup(children as React.ReactElement);\n }\n // Fallback for non-React environments\n return String(children);\n } catch {\n // Fallback for non-React environments\n return String(children);\n }\n}\n\n/**\n * Check if we're running in a browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\n/**\n * Check if we're running in a Node.js environment\n */\nexport function isServer(): boolean {\n return typeof window === 'undefined';\n}\n"]}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @frontmcp/ui Registry Module
3
+ *
4
+ * Standalone widget building without @frontmcp/sdk.
5
+ *
6
+ * This module enables external platforms (like AgentLink) to use FrontMCP's
7
+ * widget compilation and rendering system without requiring the full SDK.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import {
12
+ * ToolUIRegistry,
13
+ * renderToolTemplateAsync,
14
+ * buildStaticWidgetUri,
15
+ * } from '@frontmcp/ui/registry';
16
+ *
17
+ * // Create a registry for widget management
18
+ * const registry = new ToolUIRegistry();
19
+ *
20
+ * // Compile static widgets at startup
21
+ * await registry.compileStaticWidgetAsync({
22
+ * toolName: 'get_weather',
23
+ * template: WeatherWidget,
24
+ * uiConfig: { template: WeatherWidget, ... },
25
+ * });
26
+ *
27
+ * // Render inline widgets at tool call time
28
+ * const result = await registry.renderAndRegisterAsync({
29
+ * toolName: 'get_weather',
30
+ * requestId: 'abc123',
31
+ * input: { location: 'London' },
32
+ * output: { temp: 72 },
33
+ * uiConfig,
34
+ * platformType: 'openai',
35
+ * });
36
+ * ```
37
+ *
38
+ * @packageDocumentation
39
+ */
40
+ export { ToolUIRegistry } from './tool-ui.registry';
41
+ export type { RenderOptions, UIRenderResult, CompileStaticWidgetOptions, HybridComponentPayload, BuildHybridComponentPayloadOptions, } from './tool-ui.registry';
42
+ export { renderToolTemplate, renderToolTemplateAsync, isReactComponent, hasUIConfig, containsMdxSyntax, } from './render-template';
43
+ export type { RenderTemplateOptions } from './render-template';
44
+ export { UI_RESOURCE_SCHEME, isUIResourceUri, isStaticWidgetUri, parseWidgetUri, buildStaticWidgetUri, getUIResourceMimeType, } from './uri-utils';
45
+ export type { ParsedWidgetUri } from './uri-utils';
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * @frontmcp/ui Registry Module
4
+ *
5
+ * Standalone widget building without @frontmcp/sdk.
6
+ *
7
+ * This module enables external platforms (like AgentLink) to use FrontMCP's
8
+ * widget compilation and rendering system without requiring the full SDK.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import {
13
+ * ToolUIRegistry,
14
+ * renderToolTemplateAsync,
15
+ * buildStaticWidgetUri,
16
+ * } from '@frontmcp/ui/registry';
17
+ *
18
+ * // Create a registry for widget management
19
+ * const registry = new ToolUIRegistry();
20
+ *
21
+ * // Compile static widgets at startup
22
+ * await registry.compileStaticWidgetAsync({
23
+ * toolName: 'get_weather',
24
+ * template: WeatherWidget,
25
+ * uiConfig: { template: WeatherWidget, ... },
26
+ * });
27
+ *
28
+ * // Render inline widgets at tool call time
29
+ * const result = await registry.renderAndRegisterAsync({
30
+ * toolName: 'get_weather',
31
+ * requestId: 'abc123',
32
+ * input: { location: 'London' },
33
+ * output: { temp: 72 },
34
+ * uiConfig,
35
+ * platformType: 'openai',
36
+ * });
37
+ * ```
38
+ *
39
+ * @packageDocumentation
40
+ */
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.getUIResourceMimeType = exports.buildStaticWidgetUri = exports.parseWidgetUri = exports.isStaticWidgetUri = exports.isUIResourceUri = exports.UI_RESOURCE_SCHEME = exports.containsMdxSyntax = exports.hasUIConfig = exports.isReactComponent = exports.renderToolTemplateAsync = exports.renderToolTemplate = exports.ToolUIRegistry = void 0;
43
+ // ============================================
44
+ // Core Registry
45
+ // ============================================
46
+ var tool_ui_registry_1 = require("./tool-ui.registry");
47
+ Object.defineProperty(exports, "ToolUIRegistry", { enumerable: true, get: function () { return tool_ui_registry_1.ToolUIRegistry; } });
48
+ // ============================================
49
+ // Template Rendering
50
+ // ============================================
51
+ var render_template_1 = require("./render-template");
52
+ Object.defineProperty(exports, "renderToolTemplate", { enumerable: true, get: function () { return render_template_1.renderToolTemplate; } });
53
+ Object.defineProperty(exports, "renderToolTemplateAsync", { enumerable: true, get: function () { return render_template_1.renderToolTemplateAsync; } });
54
+ Object.defineProperty(exports, "isReactComponent", { enumerable: true, get: function () { return render_template_1.isReactComponent; } });
55
+ Object.defineProperty(exports, "hasUIConfig", { enumerable: true, get: function () { return render_template_1.hasUIConfig; } });
56
+ Object.defineProperty(exports, "containsMdxSyntax", { enumerable: true, get: function () { return render_template_1.containsMdxSyntax; } });
57
+ // ============================================
58
+ // URI Utilities
59
+ // ============================================
60
+ var uri_utils_1 = require("./uri-utils");
61
+ Object.defineProperty(exports, "UI_RESOURCE_SCHEME", { enumerable: true, get: function () { return uri_utils_1.UI_RESOURCE_SCHEME; } });
62
+ Object.defineProperty(exports, "isUIResourceUri", { enumerable: true, get: function () { return uri_utils_1.isUIResourceUri; } });
63
+ Object.defineProperty(exports, "isStaticWidgetUri", { enumerable: true, get: function () { return uri_utils_1.isStaticWidgetUri; } });
64
+ Object.defineProperty(exports, "parseWidgetUri", { enumerable: true, get: function () { return uri_utils_1.parseWidgetUri; } });
65
+ Object.defineProperty(exports, "buildStaticWidgetUri", { enumerable: true, get: function () { return uri_utils_1.buildStaticWidgetUri; } });
66
+ Object.defineProperty(exports, "getUIResourceMimeType", { enumerable: true, get: function () { return uri_utils_1.getUIResourceMimeType; } });
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/registry/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;;AAEH,+CAA+C;AAC/C,gBAAgB;AAChB,+CAA+C;AAE/C,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AASvB,+CAA+C;AAC/C,qBAAqB;AACrB,+CAA+C;AAE/C,qDAM2B;AALzB,qHAAA,kBAAkB,OAAA;AAClB,0HAAA,uBAAuB,OAAA;AACvB,mHAAA,gBAAgB,OAAA;AAChB,8GAAA,WAAW,OAAA;AACX,oHAAA,iBAAiB,OAAA;AAInB,+CAA+C;AAC/C,gBAAgB;AAChB,+CAA+C;AAE/C,yCAOqB;AANnB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,kHAAA,qBAAqB,OAAA","sourcesContent":["/**\n * @frontmcp/ui Registry Module\n *\n * Standalone widget building without @frontmcp/sdk.\n *\n * This module enables external platforms (like AgentLink) to use FrontMCP's\n * widget compilation and rendering system without requiring the full SDK.\n *\n * @example\n * ```typescript\n * import {\n * ToolUIRegistry,\n * renderToolTemplateAsync,\n * buildStaticWidgetUri,\n * } from '@frontmcp/ui/registry';\n *\n * // Create a registry for widget management\n * const registry = new ToolUIRegistry();\n *\n * // Compile static widgets at startup\n * await registry.compileStaticWidgetAsync({\n * toolName: 'get_weather',\n * template: WeatherWidget,\n * uiConfig: { template: WeatherWidget, ... },\n * });\n *\n * // Render inline widgets at tool call time\n * const result = await registry.renderAndRegisterAsync({\n * toolName: 'get_weather',\n * requestId: 'abc123',\n * input: { location: 'London' },\n * output: { temp: 72 },\n * uiConfig,\n * platformType: 'openai',\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// ============================================\n// Core Registry\n// ============================================\n\nexport { ToolUIRegistry } from './tool-ui.registry';\nexport type {\n RenderOptions,\n UIRenderResult,\n CompileStaticWidgetOptions,\n HybridComponentPayload,\n BuildHybridComponentPayloadOptions,\n} from './tool-ui.registry';\n\n// ============================================\n// Template Rendering\n// ============================================\n\nexport {\n renderToolTemplate,\n renderToolTemplateAsync,\n isReactComponent,\n hasUIConfig,\n containsMdxSyntax,\n} from './render-template';\nexport type { RenderTemplateOptions } from './render-template';\n\n// ============================================\n// URI Utilities\n// ============================================\n\nexport {\n UI_RESOURCE_SCHEME,\n isUIResourceUri,\n isStaticWidgetUri,\n parseWidgetUri,\n buildStaticWidgetUri,\n getUIResourceMimeType,\n} from './uri-utils';\nexport type { ParsedWidgetUri } from './uri-utils';\n"]}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Template Rendering
3
+ *
4
+ * Executes tool UI templates with proper context and helpers.
5
+ * Supports sync rendering for HTML strings/template functions,
6
+ * async rendering for React components via SSR, and MDX rendering.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import type { UITemplateConfig, TemplateBuilderFn } from '../types';
11
+ /**
12
+ * Check if a string contains MDX syntax (Markdown + JSX).
13
+ *
14
+ * Looks for:
15
+ * - JSX component tags (PascalCase): `<Component />`
16
+ * - JS expressions: `{variable}` or `{items.map(...)}`
17
+ * - Import/export statements
18
+ * - Frontmatter: `---\n...\n---`
19
+ */
20
+ export declare function containsMdxSyntax(source: string): boolean;
21
+ /**
22
+ * Check if a template is a React component (not a template builder function).
23
+ *
24
+ * React components are distinguished from template builder functions by:
25
+ * - Having $$typeof symbol (React.memo, forwardRef, etc.)
26
+ * - Having prototype.isReactComponent (class components)
27
+ * - PascalCase naming convention (function components)
28
+ *
29
+ * Template builder functions take (ctx) and return a string, while
30
+ * React components take props and return JSX.Element.
31
+ */
32
+ export declare function isReactComponent(template: unknown): boolean;
33
+ /**
34
+ * Options for rendering a tool template.
35
+ */
36
+ export interface RenderTemplateOptions {
37
+ /** The template configuration from the tool */
38
+ template: TemplateBuilderFn<unknown, unknown> | string | ((props: any) => any);
39
+ /** Tool input arguments */
40
+ input: Record<string, unknown>;
41
+ /** Tool output (raw result from execute) */
42
+ output: unknown;
43
+ /** Structured content parsed from output */
44
+ structuredContent?: unknown;
45
+ /** Custom MDX components to use in MDX templates */
46
+ mdxComponents?: Record<string, any>;
47
+ }
48
+ /**
49
+ * Render a tool UI template.
50
+ *
51
+ * @param options - Template and context data
52
+ * @returns Rendered HTML string
53
+ * @throws Error if template execution fails
54
+ */
55
+ export declare function renderToolTemplate(options: RenderTemplateOptions): string;
56
+ /**
57
+ * Check if a tool has UI configuration.
58
+ * Uses loose typing to handle variance issues with generic tool metadata.
59
+ */
60
+ export declare function hasUIConfig(metadata: {
61
+ ui?: unknown;
62
+ }): metadata is {
63
+ ui: UITemplateConfig<unknown, unknown>;
64
+ };
65
+ /**
66
+ * Render a tool UI template asynchronously.
67
+ *
68
+ * This version supports:
69
+ * - React components via SSR
70
+ * - MDX strings (Markdown + JSX) via @mdx-js/mdx
71
+ * - HTML strings and template builder functions
72
+ *
73
+ * For React components:
74
+ * - Dynamically imports react and react-dom/server
75
+ * - Uses renderToString for SSR
76
+ * - React components receive the template context as props
77
+ *
78
+ * For MDX templates:
79
+ * - Detects MDX syntax (Markdown headers, JSX components, expressions)
80
+ * - Compiles and renders via @frontmcp/ui's MDX renderer
81
+ *
82
+ * @param options - Template and context data
83
+ * @returns Promise resolving to rendered HTML string
84
+ * @throws Error if template execution or rendering fails
85
+ */
86
+ export declare function renderToolTemplateAsync(options: RenderTemplateOptions): Promise<string>;