@frontmcp/ui 0.6.0 → 0.6.1

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 (445) hide show
  1. package/README.md +140 -362
  2. package/bridge/runtime/index.d.ts +2 -1
  3. package/bridge/runtime/index.d.ts.map +1 -1
  4. package/bundler/file-cache/component-builder.d.ts +1 -1
  5. package/bundler/file-cache/component-builder.d.ts.map +1 -1
  6. package/bundler/file-cache/hash-calculator.d.ts +1 -1
  7. package/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  8. package/bundler/file-cache/storage/filesystem.d.ts +1 -1
  9. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  10. package/bundler/file-cache/storage/interface.d.ts +1 -1
  11. package/bundler/file-cache/storage/interface.d.ts.map +1 -1
  12. package/bundler/file-cache/storage/redis.d.ts +1 -1
  13. package/bundler/file-cache/storage/redis.d.ts.map +1 -1
  14. package/bundler/index.js +10 -1057
  15. package/components/alert.schema.d.ts +6 -6
  16. package/components/avatar.schema.d.ts +9 -9
  17. package/components/badge.schema.d.ts +9 -9
  18. package/components/button.schema.d.ts +9 -9
  19. package/components/card.schema.d.ts +7 -7
  20. package/components/form.schema.d.ts +24 -24
  21. package/components/index.js +128 -198
  22. package/components/modal.schema.d.ts +8 -8
  23. package/components/table.schema.d.ts +6 -6
  24. package/esm/bridge/runtime/index.d.ts +2 -1
  25. package/esm/bridge/runtime/index.d.ts.map +1 -1
  26. package/esm/bundler/file-cache/component-builder.d.ts +1 -1
  27. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -1
  28. package/esm/bundler/file-cache/hash-calculator.d.ts +1 -1
  29. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  30. package/esm/bundler/file-cache/storage/filesystem.d.ts +1 -1
  31. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  32. package/esm/bundler/file-cache/storage/interface.d.ts +1 -1
  33. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -1
  34. package/esm/bundler/file-cache/storage/redis.d.ts +1 -1
  35. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -1
  36. package/esm/bundler/index.js +3 -1050
  37. package/esm/components/alert.schema.d.ts +6 -6
  38. package/esm/components/avatar.schema.d.ts +9 -9
  39. package/esm/components/badge.schema.d.ts +9 -9
  40. package/esm/components/button.schema.d.ts +9 -9
  41. package/esm/components/card.schema.d.ts +7 -7
  42. package/esm/components/form.schema.d.ts +24 -24
  43. package/esm/components/index.js +136 -196
  44. package/esm/components/modal.schema.d.ts +8 -8
  45. package/esm/components/table.schema.d.ts +6 -6
  46. package/esm/index.d.ts +23 -39
  47. package/esm/index.d.ts.map +1 -1
  48. package/esm/index.js +4256 -16441
  49. package/esm/layouts/base.d.ts +2 -2
  50. package/esm/layouts/base.d.ts.map +1 -1
  51. package/esm/layouts/index.js +33 -516
  52. package/esm/package.json +8 -26
  53. package/esm/pages/index.js +100 -627
  54. package/esm/react/Alert.d.ts +1 -2
  55. package/esm/react/Alert.d.ts.map +1 -1
  56. package/esm/react/Badge.d.ts +1 -2
  57. package/esm/react/Badge.d.ts.map +1 -1
  58. package/esm/react/Button.d.ts +1 -2
  59. package/esm/react/Button.d.ts.map +1 -1
  60. package/esm/react/Card.d.ts +1 -2
  61. package/esm/react/Card.d.ts.map +1 -1
  62. package/esm/react/hooks/context.d.ts +1 -1
  63. package/esm/react/hooks/context.d.ts.map +1 -1
  64. package/esm/react/index.d.ts +5 -6
  65. package/esm/react/index.d.ts.map +1 -1
  66. package/esm/react/index.js +2074 -322
  67. package/esm/react/types.d.ts +1 -2
  68. package/esm/react/types.d.ts.map +1 -1
  69. package/esm/renderers/index.d.ts +10 -25
  70. package/esm/renderers/index.d.ts.map +1 -1
  71. package/esm/renderers/index.js +171 -1617
  72. package/esm/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  73. package/esm/renderers/react.adapter.d.ts.map +1 -0
  74. package/esm/renderers/react.renderer.d.ts +3 -3
  75. package/esm/renderers/react.renderer.d.ts.map +1 -1
  76. package/esm/universal/index.js +1755 -0
  77. package/esm/web-components/index.js +232 -287
  78. package/esm/widgets/index.js +89 -147
  79. package/index.d.ts +23 -39
  80. package/index.d.ts.map +1 -1
  81. package/index.js +6123 -18539
  82. package/layouts/base.d.ts +2 -2
  83. package/layouts/base.d.ts.map +1 -1
  84. package/layouts/index.js +43 -536
  85. package/package.json +8 -26
  86. package/pages/index.js +111 -648
  87. package/react/Alert.d.ts +1 -2
  88. package/react/Alert.d.ts.map +1 -1
  89. package/react/Badge.d.ts +1 -2
  90. package/react/Badge.d.ts.map +1 -1
  91. package/react/Button.d.ts +1 -2
  92. package/react/Button.d.ts.map +1 -1
  93. package/react/Card.d.ts +1 -2
  94. package/react/Card.d.ts.map +1 -1
  95. package/react/hooks/context.d.ts +1 -1
  96. package/react/hooks/context.d.ts.map +1 -1
  97. package/react/index.d.ts +5 -6
  98. package/react/index.d.ts.map +1 -1
  99. package/react/index.js +2065 -335
  100. package/react/types.d.ts +1 -2
  101. package/react/types.d.ts.map +1 -1
  102. package/renderers/index.d.ts +10 -25
  103. package/renderers/index.d.ts.map +1 -1
  104. package/renderers/index.js +175 -1641
  105. package/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  106. package/renderers/react.adapter.d.ts.map +1 -0
  107. package/renderers/react.renderer.d.ts +3 -3
  108. package/renderers/react.renderer.d.ts.map +1 -1
  109. package/universal/index.js +1841 -0
  110. package/web-components/index.js +224 -289
  111. package/widgets/index.js +80 -148
  112. package/adapters/index.d.ts +0 -13
  113. package/adapters/index.d.ts.map +0 -1
  114. package/adapters/index.js +0 -462
  115. package/adapters/platform-meta.d.ts +0 -166
  116. package/adapters/platform-meta.d.ts.map +0 -1
  117. package/adapters/response-builder.d.ts +0 -108
  118. package/adapters/response-builder.d.ts.map +0 -1
  119. package/adapters/serving-mode.d.ts +0 -107
  120. package/adapters/serving-mode.d.ts.map +0 -1
  121. package/base-template/bridge.d.ts +0 -90
  122. package/base-template/bridge.d.ts.map +0 -1
  123. package/base-template/default-base-template.d.ts +0 -92
  124. package/base-template/default-base-template.d.ts.map +0 -1
  125. package/base-template/index.d.ts +0 -15
  126. package/base-template/index.d.ts.map +0 -1
  127. package/base-template/index.js +0 -1398
  128. package/base-template/polyfills.d.ts +0 -31
  129. package/base-template/polyfills.d.ts.map +0 -1
  130. package/base-template/theme-styles.d.ts +0 -74
  131. package/base-template/theme-styles.d.ts.map +0 -1
  132. package/build/cdn-resources.d.ts +0 -243
  133. package/build/cdn-resources.d.ts.map +0 -1
  134. package/build/index.d.ts +0 -295
  135. package/build/index.d.ts.map +0 -1
  136. package/build/index.js +0 -7096
  137. package/build/widget-manifest.d.ts +0 -362
  138. package/build/widget-manifest.d.ts.map +0 -1
  139. package/dependency/cdn-registry.d.ts +0 -98
  140. package/dependency/cdn-registry.d.ts.map +0 -1
  141. package/dependency/import-map.d.ts +0 -186
  142. package/dependency/import-map.d.ts.map +0 -1
  143. package/dependency/import-parser.d.ts +0 -82
  144. package/dependency/import-parser.d.ts.map +0 -1
  145. package/dependency/index.d.ts +0 -17
  146. package/dependency/index.d.ts.map +0 -1
  147. package/dependency/resolver.d.ts +0 -164
  148. package/dependency/resolver.d.ts.map +0 -1
  149. package/dependency/schemas.d.ts +0 -486
  150. package/dependency/schemas.d.ts.map +0 -1
  151. package/dependency/template-loader.d.ts +0 -204
  152. package/dependency/template-loader.d.ts.map +0 -1
  153. package/dependency/template-processor.d.ts +0 -118
  154. package/dependency/template-processor.d.ts.map +0 -1
  155. package/dependency/types.d.ts +0 -739
  156. package/dependency/types.d.ts.map +0 -1
  157. package/esm/adapters/index.d.ts +0 -13
  158. package/esm/adapters/index.d.ts.map +0 -1
  159. package/esm/adapters/index.js +0 -427
  160. package/esm/adapters/platform-meta.d.ts +0 -166
  161. package/esm/adapters/platform-meta.d.ts.map +0 -1
  162. package/esm/adapters/response-builder.d.ts +0 -108
  163. package/esm/adapters/response-builder.d.ts.map +0 -1
  164. package/esm/adapters/serving-mode.d.ts +0 -107
  165. package/esm/adapters/serving-mode.d.ts.map +0 -1
  166. package/esm/base-template/bridge.d.ts +0 -90
  167. package/esm/base-template/bridge.d.ts.map +0 -1
  168. package/esm/base-template/default-base-template.d.ts +0 -92
  169. package/esm/base-template/default-base-template.d.ts.map +0 -1
  170. package/esm/base-template/index.d.ts +0 -15
  171. package/esm/base-template/index.d.ts.map +0 -1
  172. package/esm/base-template/index.js +0 -1364
  173. package/esm/base-template/polyfills.d.ts +0 -31
  174. package/esm/base-template/polyfills.d.ts.map +0 -1
  175. package/esm/base-template/theme-styles.d.ts +0 -74
  176. package/esm/base-template/theme-styles.d.ts.map +0 -1
  177. package/esm/build/cdn-resources.d.ts +0 -243
  178. package/esm/build/cdn-resources.d.ts.map +0 -1
  179. package/esm/build/index.d.ts +0 -295
  180. package/esm/build/index.d.ts.map +0 -1
  181. package/esm/build/index.js +0 -7021
  182. package/esm/build/widget-manifest.d.ts +0 -362
  183. package/esm/build/widget-manifest.d.ts.map +0 -1
  184. package/esm/dependency/cdn-registry.d.ts +0 -98
  185. package/esm/dependency/cdn-registry.d.ts.map +0 -1
  186. package/esm/dependency/import-map.d.ts +0 -186
  187. package/esm/dependency/import-map.d.ts.map +0 -1
  188. package/esm/dependency/import-parser.d.ts +0 -82
  189. package/esm/dependency/import-parser.d.ts.map +0 -1
  190. package/esm/dependency/index.d.ts +0 -17
  191. package/esm/dependency/index.d.ts.map +0 -1
  192. package/esm/dependency/resolver.d.ts +0 -164
  193. package/esm/dependency/resolver.d.ts.map +0 -1
  194. package/esm/dependency/schemas.d.ts +0 -486
  195. package/esm/dependency/schemas.d.ts.map +0 -1
  196. package/esm/dependency/template-loader.d.ts +0 -204
  197. package/esm/dependency/template-loader.d.ts.map +0 -1
  198. package/esm/dependency/template-processor.d.ts +0 -118
  199. package/esm/dependency/template-processor.d.ts.map +0 -1
  200. package/esm/dependency/types.d.ts +0 -739
  201. package/esm/dependency/types.d.ts.map +0 -1
  202. package/esm/handlebars/expression-extractor.d.ts +0 -147
  203. package/esm/handlebars/expression-extractor.d.ts.map +0 -1
  204. package/esm/handlebars/helpers.d.ts +0 -339
  205. package/esm/handlebars/helpers.d.ts.map +0 -1
  206. package/esm/handlebars/index.d.ts +0 -195
  207. package/esm/handlebars/index.d.ts.map +0 -1
  208. package/esm/handlebars/index.js +0 -587
  209. package/esm/registry/index.d.ts +0 -46
  210. package/esm/registry/index.d.ts.map +0 -1
  211. package/esm/registry/index.js +0 -6422
  212. package/esm/registry/render-template.d.ts +0 -91
  213. package/esm/registry/render-template.d.ts.map +0 -1
  214. package/esm/registry/tool-ui.registry.d.ts +0 -294
  215. package/esm/registry/tool-ui.registry.d.ts.map +0 -1
  216. package/esm/registry/uri-utils.d.ts +0 -56
  217. package/esm/registry/uri-utils.d.ts.map +0 -1
  218. package/esm/renderers/cache.d.ts +0 -145
  219. package/esm/renderers/cache.d.ts.map +0 -1
  220. package/esm/renderers/html.renderer.d.ts +0 -123
  221. package/esm/renderers/html.renderer.d.ts.map +0 -1
  222. package/esm/renderers/mdx.renderer.d.ts +0 -120
  223. package/esm/renderers/mdx.renderer.d.ts.map +0 -1
  224. package/esm/renderers/registry.d.ts +0 -134
  225. package/esm/renderers/registry.d.ts.map +0 -1
  226. package/esm/renderers/types.d.ts +0 -342
  227. package/esm/renderers/types.d.ts.map +0 -1
  228. package/esm/renderers/utils/detect.d.ts +0 -107
  229. package/esm/renderers/utils/detect.d.ts.map +0 -1
  230. package/esm/renderers/utils/hash.d.ts +0 -40
  231. package/esm/renderers/utils/hash.d.ts.map +0 -1
  232. package/esm/renderers/utils/index.d.ts +0 -9
  233. package/esm/renderers/utils/index.d.ts.map +0 -1
  234. package/esm/renderers/utils/transpiler.d.ts +0 -89
  235. package/esm/renderers/utils/transpiler.d.ts.map +0 -1
  236. package/esm/runtime/adapters/html.adapter.d.ts +0 -59
  237. package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
  238. package/esm/runtime/adapters/index.d.ts +0 -26
  239. package/esm/runtime/adapters/index.d.ts.map +0 -1
  240. package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
  241. package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  242. package/esm/runtime/adapters/react.adapter.d.ts.map +0 -1
  243. package/esm/runtime/adapters/types.d.ts +0 -95
  244. package/esm/runtime/adapters/types.d.ts.map +0 -1
  245. package/esm/runtime/csp.d.ts +0 -48
  246. package/esm/runtime/csp.d.ts.map +0 -1
  247. package/esm/runtime/index.d.ts +0 -17
  248. package/esm/runtime/index.d.ts.map +0 -1
  249. package/esm/runtime/index.js +0 -5186
  250. package/esm/runtime/mcp-bridge.d.ts +0 -101
  251. package/esm/runtime/mcp-bridge.d.ts.map +0 -1
  252. package/esm/runtime/renderer-runtime.d.ts +0 -133
  253. package/esm/runtime/renderer-runtime.d.ts.map +0 -1
  254. package/esm/runtime/sanitizer.d.ts +0 -172
  255. package/esm/runtime/sanitizer.d.ts.map +0 -1
  256. package/esm/runtime/types.d.ts +0 -415
  257. package/esm/runtime/types.d.ts.map +0 -1
  258. package/esm/runtime/wrapper.d.ts +0 -421
  259. package/esm/runtime/wrapper.d.ts.map +0 -1
  260. package/esm/styles/index.d.ts +0 -8
  261. package/esm/styles/index.d.ts.map +0 -1
  262. package/esm/styles/index.js +0 -171
  263. package/esm/styles/variants.d.ts +0 -51
  264. package/esm/styles/variants.d.ts.map +0 -1
  265. package/esm/theme/cdn.d.ts +0 -195
  266. package/esm/theme/cdn.d.ts.map +0 -1
  267. package/esm/theme/index.d.ts +0 -18
  268. package/esm/theme/index.d.ts.map +0 -1
  269. package/esm/theme/index.js +0 -700
  270. package/esm/theme/platforms.d.ts +0 -107
  271. package/esm/theme/platforms.d.ts.map +0 -1
  272. package/esm/theme/presets/github-openai.d.ts +0 -50
  273. package/esm/theme/presets/github-openai.d.ts.map +0 -1
  274. package/esm/theme/presets/index.d.ts +0 -11
  275. package/esm/theme/presets/index.d.ts.map +0 -1
  276. package/esm/theme/theme.d.ts +0 -396
  277. package/esm/theme/theme.d.ts.map +0 -1
  278. package/esm/tool-template/builder.d.ts +0 -213
  279. package/esm/tool-template/builder.d.ts.map +0 -1
  280. package/esm/tool-template/index.d.ts +0 -16
  281. package/esm/tool-template/index.d.ts.map +0 -1
  282. package/esm/tool-template/index.js +0 -3515
  283. package/esm/types/index.d.ts +0 -14
  284. package/esm/types/index.d.ts.map +0 -1
  285. package/esm/types/index.js +0 -75
  286. package/esm/types/ui-config.d.ts +0 -639
  287. package/esm/types/ui-config.d.ts.map +0 -1
  288. package/esm/types/ui-runtime.d.ts +0 -1007
  289. package/esm/types/ui-runtime.d.ts.map +0 -1
  290. package/esm/typings/cache/cache-adapter.d.ts +0 -125
  291. package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
  292. package/esm/typings/cache/index.d.ts +0 -10
  293. package/esm/typings/cache/index.d.ts.map +0 -1
  294. package/esm/typings/cache/memory-cache.d.ts +0 -92
  295. package/esm/typings/cache/memory-cache.d.ts.map +0 -1
  296. package/esm/typings/dts-parser.d.ts +0 -90
  297. package/esm/typings/dts-parser.d.ts.map +0 -1
  298. package/esm/typings/index.d.ts +0 -48
  299. package/esm/typings/index.d.ts.map +0 -1
  300. package/esm/typings/schemas.d.ts +0 -232
  301. package/esm/typings/schemas.d.ts.map +0 -1
  302. package/esm/typings/type-fetcher.d.ts +0 -89
  303. package/esm/typings/type-fetcher.d.ts.map +0 -1
  304. package/esm/typings/types.d.ts +0 -320
  305. package/esm/typings/types.d.ts.map +0 -1
  306. package/esm/utils/escape-html.d.ts +0 -58
  307. package/esm/utils/escape-html.d.ts.map +0 -1
  308. package/esm/utils/index.d.ts +0 -10
  309. package/esm/utils/index.d.ts.map +0 -1
  310. package/esm/utils/index.js +0 -40
  311. package/esm/utils/safe-stringify.d.ts +0 -30
  312. package/esm/utils/safe-stringify.d.ts.map +0 -1
  313. package/esm/validation/error-box.d.ts +0 -56
  314. package/esm/validation/error-box.d.ts.map +0 -1
  315. package/esm/validation/index.d.ts +0 -13
  316. package/esm/validation/index.d.ts.map +0 -1
  317. package/esm/validation/index.js +0 -562
  318. package/esm/validation/schema-paths.d.ts +0 -118
  319. package/esm/validation/schema-paths.d.ts.map +0 -1
  320. package/esm/validation/template-validator.d.ts +0 -143
  321. package/esm/validation/template-validator.d.ts.map +0 -1
  322. package/esm/validation/wrapper.d.ts +0 -97
  323. package/esm/validation/wrapper.d.ts.map +0 -1
  324. package/handlebars/expression-extractor.d.ts +0 -147
  325. package/handlebars/expression-extractor.d.ts.map +0 -1
  326. package/handlebars/helpers.d.ts +0 -339
  327. package/handlebars/helpers.d.ts.map +0 -1
  328. package/handlebars/index.d.ts +0 -195
  329. package/handlebars/index.d.ts.map +0 -1
  330. package/handlebars/index.js +0 -666
  331. package/registry/index.d.ts +0 -46
  332. package/registry/index.d.ts.map +0 -1
  333. package/registry/index.js +0 -6465
  334. package/registry/render-template.d.ts +0 -91
  335. package/registry/render-template.d.ts.map +0 -1
  336. package/registry/tool-ui.registry.d.ts +0 -294
  337. package/registry/tool-ui.registry.d.ts.map +0 -1
  338. package/registry/uri-utils.d.ts +0 -56
  339. package/registry/uri-utils.d.ts.map +0 -1
  340. package/renderers/cache.d.ts +0 -145
  341. package/renderers/cache.d.ts.map +0 -1
  342. package/renderers/html.renderer.d.ts +0 -123
  343. package/renderers/html.renderer.d.ts.map +0 -1
  344. package/renderers/mdx.renderer.d.ts +0 -120
  345. package/renderers/mdx.renderer.d.ts.map +0 -1
  346. package/renderers/registry.d.ts +0 -134
  347. package/renderers/registry.d.ts.map +0 -1
  348. package/renderers/types.d.ts +0 -342
  349. package/renderers/types.d.ts.map +0 -1
  350. package/renderers/utils/detect.d.ts +0 -107
  351. package/renderers/utils/detect.d.ts.map +0 -1
  352. package/renderers/utils/hash.d.ts +0 -40
  353. package/renderers/utils/hash.d.ts.map +0 -1
  354. package/renderers/utils/index.d.ts +0 -9
  355. package/renderers/utils/index.d.ts.map +0 -1
  356. package/renderers/utils/transpiler.d.ts +0 -89
  357. package/renderers/utils/transpiler.d.ts.map +0 -1
  358. package/runtime/adapters/html.adapter.d.ts +0 -59
  359. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  360. package/runtime/adapters/index.d.ts +0 -26
  361. package/runtime/adapters/index.d.ts.map +0 -1
  362. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  363. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  364. package/runtime/adapters/react.adapter.d.ts.map +0 -1
  365. package/runtime/adapters/types.d.ts +0 -95
  366. package/runtime/adapters/types.d.ts.map +0 -1
  367. package/runtime/csp.d.ts +0 -48
  368. package/runtime/csp.d.ts.map +0 -1
  369. package/runtime/index.d.ts +0 -17
  370. package/runtime/index.d.ts.map +0 -1
  371. package/runtime/index.js +0 -5264
  372. package/runtime/mcp-bridge.d.ts +0 -101
  373. package/runtime/mcp-bridge.d.ts.map +0 -1
  374. package/runtime/renderer-runtime.d.ts +0 -133
  375. package/runtime/renderer-runtime.d.ts.map +0 -1
  376. package/runtime/sanitizer.d.ts +0 -172
  377. package/runtime/sanitizer.d.ts.map +0 -1
  378. package/runtime/types.d.ts +0 -415
  379. package/runtime/types.d.ts.map +0 -1
  380. package/runtime/wrapper.d.ts +0 -421
  381. package/runtime/wrapper.d.ts.map +0 -1
  382. package/styles/index.d.ts +0 -8
  383. package/styles/index.d.ts.map +0 -1
  384. package/styles/index.js +0 -222
  385. package/styles/variants.d.ts +0 -51
  386. package/styles/variants.d.ts.map +0 -1
  387. package/theme/cdn.d.ts +0 -195
  388. package/theme/cdn.d.ts.map +0 -1
  389. package/theme/index.d.ts +0 -18
  390. package/theme/index.d.ts.map +0 -1
  391. package/theme/index.js +0 -757
  392. package/theme/platforms.d.ts +0 -107
  393. package/theme/platforms.d.ts.map +0 -1
  394. package/theme/presets/github-openai.d.ts +0 -50
  395. package/theme/presets/github-openai.d.ts.map +0 -1
  396. package/theme/presets/index.d.ts +0 -11
  397. package/theme/presets/index.d.ts.map +0 -1
  398. package/theme/theme.d.ts +0 -396
  399. package/theme/theme.d.ts.map +0 -1
  400. package/tool-template/builder.d.ts +0 -213
  401. package/tool-template/builder.d.ts.map +0 -1
  402. package/tool-template/index.d.ts +0 -16
  403. package/tool-template/index.d.ts.map +0 -1
  404. package/tool-template/index.js +0 -3559
  405. package/types/index.d.ts +0 -14
  406. package/types/index.d.ts.map +0 -1
  407. package/types/index.js +0 -108
  408. package/types/ui-config.d.ts +0 -639
  409. package/types/ui-config.d.ts.map +0 -1
  410. package/types/ui-runtime.d.ts +0 -1007
  411. package/types/ui-runtime.d.ts.map +0 -1
  412. package/typings/cache/cache-adapter.d.ts +0 -125
  413. package/typings/cache/cache-adapter.d.ts.map +0 -1
  414. package/typings/cache/index.d.ts +0 -10
  415. package/typings/cache/index.d.ts.map +0 -1
  416. package/typings/cache/memory-cache.d.ts +0 -92
  417. package/typings/cache/memory-cache.d.ts.map +0 -1
  418. package/typings/dts-parser.d.ts +0 -90
  419. package/typings/dts-parser.d.ts.map +0 -1
  420. package/typings/index.d.ts +0 -48
  421. package/typings/index.d.ts.map +0 -1
  422. package/typings/schemas.d.ts +0 -232
  423. package/typings/schemas.d.ts.map +0 -1
  424. package/typings/type-fetcher.d.ts +0 -89
  425. package/typings/type-fetcher.d.ts.map +0 -1
  426. package/typings/types.d.ts +0 -320
  427. package/typings/types.d.ts.map +0 -1
  428. package/utils/escape-html.d.ts +0 -58
  429. package/utils/escape-html.d.ts.map +0 -1
  430. package/utils/index.d.ts +0 -10
  431. package/utils/index.d.ts.map +0 -1
  432. package/utils/index.js +0 -70
  433. package/utils/safe-stringify.d.ts +0 -30
  434. package/utils/safe-stringify.d.ts.map +0 -1
  435. package/validation/error-box.d.ts +0 -56
  436. package/validation/error-box.d.ts.map +0 -1
  437. package/validation/index.d.ts +0 -13
  438. package/validation/index.d.ts.map +0 -1
  439. package/validation/index.js +0 -603
  440. package/validation/schema-paths.d.ts +0 -118
  441. package/validation/schema-paths.d.ts.map +0 -1
  442. package/validation/template-validator.d.ts +0 -143
  443. package/validation/template-validator.d.ts.map +0 -1
  444. package/validation/wrapper.d.ts +0 -97
  445. package/validation/wrapper.d.ts.map +0 -1
@@ -0,0 +1,1755 @@
1
+ // libs/ui/src/universal/types.ts
2
+ var DEFAULT_FRONTMCP_STATE = {
3
+ toolName: null,
4
+ input: null,
5
+ output: null,
6
+ content: null,
7
+ structuredContent: null,
8
+ loading: false,
9
+ error: null
10
+ };
11
+ var UNIVERSAL_CDN = {
12
+ esm: {
13
+ reactMarkdown: "https://esm.sh/react-markdown@9",
14
+ mdxReact: "https://esm.sh/@mdx-js/react@3",
15
+ remarkGfm: "https://esm.sh/remark-gfm@4"
16
+ }
17
+ // Note: These libraries are not available on cdnjs
18
+ // For Claude, we use inline implementations
19
+ };
20
+ function detectContentType(source) {
21
+ if (typeof source === "function") {
22
+ return "react";
23
+ }
24
+ if (typeof source !== "string") {
25
+ return "html";
26
+ }
27
+ const hasModuleSyntax = /^import\s+/m.test(source) || /^export\s+(default\s+)?/m.test(source) || /^const\s+\w+\s*=\s*\([^)]*\)\s*=>/m.test(source) || // Arrow function components
28
+ /^function\s+\w+\s*\(/m.test(source);
29
+ const hasJsxTags = /<[A-Z][a-zA-Z]*/.test(source);
30
+ const hasMarkdown = /^#{1,6}\s/m.test(source) || /^\*\s/m.test(source) || /^-\s/m.test(source) || /^\d+\.\s/m.test(source);
31
+ if (hasModuleSyntax && hasJsxTags) {
32
+ return "react";
33
+ }
34
+ if (hasJsxTags && hasMarkdown && !hasModuleSyntax) {
35
+ return "mdx";
36
+ }
37
+ if (hasMarkdown || /\*\*[^*]+\*\*/.test(source) || /\[[^\]]+\]\([^)]+\)/.test(source)) {
38
+ return "markdown";
39
+ }
40
+ if (hasJsxTags && !hasModuleSyntax) {
41
+ return "mdx";
42
+ }
43
+ return "html";
44
+ }
45
+
46
+ // libs/ui/src/universal/store.ts
47
+ import { useSyncExternalStore } from "react";
48
+ function createFrontMCPStore(initialState) {
49
+ let state = {
50
+ ...DEFAULT_FRONTMCP_STATE,
51
+ ...initialState
52
+ };
53
+ const listeners = /* @__PURE__ */ new Set();
54
+ const getState = () => state;
55
+ const getServerState = () => state;
56
+ const setState = (partial) => {
57
+ const hasChanged = Object.keys(partial).some(
58
+ (key) => partial[key] !== state[key]
59
+ );
60
+ if (hasChanged) {
61
+ state = { ...state, ...partial };
62
+ listeners.forEach((listener) => listener());
63
+ }
64
+ };
65
+ const subscribe = (listener) => {
66
+ listeners.add(listener);
67
+ return () => {
68
+ listeners.delete(listener);
69
+ };
70
+ };
71
+ const reset = () => {
72
+ setState({
73
+ ...DEFAULT_FRONTMCP_STATE,
74
+ ...initialState
75
+ });
76
+ };
77
+ return {
78
+ getState,
79
+ getServerState,
80
+ setState,
81
+ subscribe,
82
+ reset
83
+ };
84
+ }
85
+ var globalStore = null;
86
+ function getGlobalStore() {
87
+ if (!globalStore) {
88
+ globalStore = createFrontMCPStore();
89
+ }
90
+ return globalStore;
91
+ }
92
+ function setGlobalStore(store) {
93
+ globalStore = store;
94
+ }
95
+ function resetGlobalStore(initialState) {
96
+ globalStore = createFrontMCPStore(initialState);
97
+ }
98
+ function useFrontMCPStore(store) {
99
+ const targetStore = store ?? getGlobalStore();
100
+ return useSyncExternalStore(targetStore.subscribe, targetStore.getState, targetStore.getServerState);
101
+ }
102
+ function useToolOutput(store) {
103
+ const state = useFrontMCPStore(store);
104
+ return state.output;
105
+ }
106
+ function useToolInput(store) {
107
+ const state = useFrontMCPStore(store);
108
+ return state.input;
109
+ }
110
+ function useContent(store) {
111
+ const state = useFrontMCPStore(store);
112
+ return state.content;
113
+ }
114
+ function useToolName(store) {
115
+ const state = useFrontMCPStore(store);
116
+ return state.toolName;
117
+ }
118
+ function useLoadingState(store) {
119
+ const state = useFrontMCPStore(store);
120
+ return { loading: state.loading, error: state.error };
121
+ }
122
+ function initializeStoreFromWindow(store) {
123
+ const targetStore = store ?? getGlobalStore();
124
+ const windowData = typeof window !== "undefined" ? window.__frontmcp : void 0;
125
+ if (windowData?.context) {
126
+ targetStore.setState({
127
+ toolName: windowData.context.toolName ?? null,
128
+ input: windowData.context.toolInput ?? null,
129
+ output: windowData.context.toolOutput ?? null,
130
+ structuredContent: windowData.context.structuredContent ?? null,
131
+ loading: false,
132
+ error: null
133
+ });
134
+ }
135
+ }
136
+ function createStoreSelector(selector) {
137
+ return (store) => {
138
+ const state = useFrontMCPStore(store);
139
+ return selector(state);
140
+ };
141
+ }
142
+
143
+ // libs/ui/src/universal/context.tsx
144
+ import { createContext, useContext, useEffect, useMemo, useRef } from "react";
145
+ import { jsx } from "react/jsx-runtime";
146
+ var FrontMCPContext = createContext(null);
147
+ var ComponentsContext = createContext({});
148
+ function FrontMCPProvider({ store, initialState, children }) {
149
+ const storeRef = useRef(null);
150
+ if (!storeRef.current) {
151
+ storeRef.current = store ?? createFrontMCPStore(initialState);
152
+ }
153
+ const actualStore = storeRef.current;
154
+ useEffect(() => {
155
+ if (typeof window !== "undefined" && !store) {
156
+ initializeStoreFromWindow(actualStore);
157
+ }
158
+ }, [actualStore, store]);
159
+ return /* @__PURE__ */ jsx(FrontMCPContext.Provider, { value: actualStore, children });
160
+ }
161
+ function ComponentsProvider({ components, children }) {
162
+ const parentComponents = useContext(ComponentsContext);
163
+ const mergedComponents = useMemo(
164
+ () => ({
165
+ ...parentComponents,
166
+ ...components
167
+ }),
168
+ [parentComponents, components]
169
+ );
170
+ return /* @__PURE__ */ jsx(ComponentsContext.Provider, { value: mergedComponents, children });
171
+ }
172
+ function useFrontMCPContext() {
173
+ const store = useContext(FrontMCPContext);
174
+ if (!store) {
175
+ throw new Error("useFrontMCPContext must be used within a FrontMCPProvider");
176
+ }
177
+ return store;
178
+ }
179
+ function useComponents() {
180
+ return useContext(ComponentsContext);
181
+ }
182
+ function useFrontMCPContextSafe() {
183
+ return useContext(FrontMCPContext);
184
+ }
185
+ function UniversalProvider({
186
+ store,
187
+ initialState,
188
+ components = {},
189
+ children
190
+ }) {
191
+ return /* @__PURE__ */ jsx(FrontMCPProvider, { store, initialState, children: /* @__PURE__ */ jsx(ComponentsProvider, { components, children }) });
192
+ }
193
+ function withFrontMCP(Component) {
194
+ const WrappedComponent = (props) => {
195
+ const store = useFrontMCPContext();
196
+ const state = store.getState();
197
+ return /* @__PURE__ */ jsx(Component, { ...props, state });
198
+ };
199
+ WrappedComponent.displayName = `withFrontMCP(${Component.displayName || Component.name || "Component"})`;
200
+ return WrappedComponent;
201
+ }
202
+
203
+ // libs/ui/src/universal/renderers/html.renderer.ts
204
+ import React2 from "react";
205
+ var htmlRenderer = {
206
+ type: "html",
207
+ priority: 0,
208
+ // Lowest priority (fallback)
209
+ canHandle(content) {
210
+ return content.type === "html" || typeof content.source === "string";
211
+ },
212
+ render(content, _context) {
213
+ const source = content.source;
214
+ if (typeof source !== "string") {
215
+ return React2.createElement("div", { className: "frontmcp-error" }, "HTML renderer requires a string source");
216
+ }
217
+ return React2.createElement("div", {
218
+ className: "frontmcp-html-content",
219
+ dangerouslySetInnerHTML: { __html: source }
220
+ });
221
+ }
222
+ };
223
+ function sanitizeHtml(html) {
224
+ let sanitized = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
225
+ sanitized = sanitized.replace(/\s+on\w+\s*=\s*["'][^"']*["']/gi, "");
226
+ sanitized = sanitized.replace(/\s+on\w+\s*=\s*[^\s>]*/gi, "");
227
+ sanitized = sanitized.replace(/href\s*=\s*["']javascript:[^"']*["']/gi, 'href="#"');
228
+ return sanitized;
229
+ }
230
+ var safeHtmlRenderer = {
231
+ type: "html",
232
+ priority: 0,
233
+ canHandle(content) {
234
+ return content.type === "html" && typeof content.source === "string";
235
+ },
236
+ render(content, _context) {
237
+ const source = content.source;
238
+ if (typeof source !== "string") {
239
+ return React2.createElement("div", { className: "frontmcp-error" }, "HTML renderer requires a string source");
240
+ }
241
+ const sanitized = sanitizeHtml(source);
242
+ return React2.createElement("div", {
243
+ className: "frontmcp-html-content",
244
+ dangerouslySetInnerHTML: { __html: sanitized }
245
+ });
246
+ }
247
+ };
248
+
249
+ // libs/ui/src/universal/renderers/markdown.renderer.ts
250
+ import React3 from "react";
251
+ import { escapeHtml } from "@frontmcp/uipack/utils";
252
+ function isSafeUrl(url) {
253
+ if (!url) return false;
254
+ const lower = url.toLowerCase().trim();
255
+ return lower.startsWith("http://") || lower.startsWith("https://") || lower.startsWith("/") || lower.startsWith("#") || lower.startsWith("mailto:") || lower.startsWith("tel:");
256
+ }
257
+ function getReactMarkdown() {
258
+ if (typeof window !== "undefined" && window.ReactMarkdown) {
259
+ return window.ReactMarkdown;
260
+ }
261
+ return null;
262
+ }
263
+ function parseMarkdownToHtml(markdown) {
264
+ let html = escapeHtml(markdown);
265
+ html = html.replace(/^######\s+(.*)$/gm, "<h6>$1</h6>");
266
+ html = html.replace(/^#####\s+(.*)$/gm, "<h5>$1</h5>");
267
+ html = html.replace(/^####\s+(.*)$/gm, "<h4>$1</h4>");
268
+ html = html.replace(/^###\s+(.*)$/gm, "<h3>$1</h3>");
269
+ html = html.replace(/^##\s+(.*)$/gm, "<h2>$1</h2>");
270
+ html = html.replace(/^#\s+(.*)$/gm, "<h1>$1</h1>");
271
+ html = html.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>");
272
+ html = html.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>");
273
+ html = html.replace(/\*(.+?)\*/g, "<em>$1</em>");
274
+ html = html.replace(/___(.+?)___/g, "<strong><em>$1</em></strong>");
275
+ html = html.replace(/__(.+?)__/g, "<strong>$1</strong>");
276
+ html = html.replace(/_(.+?)_/g, "<em>$1</em>");
277
+ html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
278
+ html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, text, url) => {
279
+ return isSafeUrl(url) ? `<a href="${url}">${text}</a>` : text;
280
+ });
281
+ html = html.replace(/^[-*]\s+(.*)$/gm, "<li>$1</li>");
282
+ html = html.replace(/(<li>.*<\/li>\n?)+/g, "<ul>$&</ul>");
283
+ html = html.replace(/^\d+\.\s+(.*)$/gm, "<li>$1</li>");
284
+ html = html.replace(/\n\n+/g, "</p><p>");
285
+ html = "<p>" + html + "</p>";
286
+ html = html.replace(/<p>\s*<\/p>/g, "");
287
+ html = html.replace(/<p>\s*(<h[1-6]>)/g, "$1");
288
+ html = html.replace(/(<\/h[1-6]>)\s*<\/p>/g, "$1");
289
+ html = html.replace(/<p>\s*(<ul>)/g, "$1");
290
+ html = html.replace(/(<\/ul>)\s*<\/p>/g, "$1");
291
+ return html;
292
+ }
293
+ var markdownRenderer = {
294
+ type: "markdown",
295
+ priority: 10,
296
+ // Medium priority
297
+ canHandle(content) {
298
+ if (content.type === "markdown") {
299
+ return true;
300
+ }
301
+ if (typeof content.source === "string") {
302
+ const source = content.source;
303
+ const hasMarkdown = /^#{1,6}\s/m.test(source) || // Headers
304
+ /^\*\s/m.test(source) || // Unordered list
305
+ /^-\s/m.test(source) || // Unordered list
306
+ /^\d+\.\s/m.test(source) || // Ordered list
307
+ /\*\*[^*]+\*\*/.test(source) || // Bold
308
+ /\[[^\]]+\]\([^)]+\)/.test(source);
309
+ const hasJsx = /<[A-Z][a-zA-Z]*/.test(source);
310
+ return hasMarkdown && !hasJsx;
311
+ }
312
+ return false;
313
+ },
314
+ render(content, context) {
315
+ const source = content.source;
316
+ if (typeof source !== "string") {
317
+ return React3.createElement("div", { className: "frontmcp-error" }, "Markdown renderer requires a string source");
318
+ }
319
+ const ReactMarkdown = getReactMarkdown();
320
+ if (ReactMarkdown) {
321
+ const components = {
322
+ ...context.components,
323
+ ...content.components
324
+ };
325
+ return React3.createElement(ReactMarkdown, { components }, source);
326
+ }
327
+ const html = parseMarkdownToHtml(source);
328
+ return React3.createElement("div", {
329
+ className: "frontmcp-markdown-content prose",
330
+ dangerouslySetInnerHTML: { __html: html }
331
+ });
332
+ }
333
+ };
334
+ function createMarkdownRenderer(defaultComponents) {
335
+ return {
336
+ ...markdownRenderer,
337
+ render(content, context) {
338
+ const enhancedContext = {
339
+ ...context,
340
+ components: {
341
+ ...defaultComponents,
342
+ ...context.components
343
+ }
344
+ };
345
+ return markdownRenderer.render(content, enhancedContext);
346
+ }
347
+ };
348
+ }
349
+
350
+ // libs/ui/src/universal/renderers/react.renderer.ts
351
+ import React4 from "react";
352
+ var reactRenderer = {
353
+ type: "react",
354
+ priority: 30,
355
+ // Highest priority for function components
356
+ canHandle(content) {
357
+ return content.type === "react" || typeof content.source === "function";
358
+ },
359
+ render(content, context) {
360
+ const Component = content.source;
361
+ if (typeof Component !== "function") {
362
+ return React4.createElement("div", {
363
+ className: "frontmcp-error",
364
+ children: "React renderer requires a component function"
365
+ });
366
+ }
367
+ const props = {
368
+ // Default props from context
369
+ output: context.output,
370
+ input: context.input,
371
+ state: context.state,
372
+ // Override with content-specific props
373
+ ...content.props
374
+ };
375
+ return React4.createElement(Component, props);
376
+ }
377
+ };
378
+ function isReactComponent(value) {
379
+ if (typeof value !== "function") {
380
+ return false;
381
+ }
382
+ const fn = value;
383
+ const typeofSymbol = fn.$$typeof;
384
+ if (typeofSymbol) {
385
+ const symbolString = typeofSymbol.toString();
386
+ return symbolString.includes("react.memo") || symbolString.includes("react.forward_ref") || symbolString.includes("react.lazy");
387
+ }
388
+ if (fn.prototype?.isReactComponent) {
389
+ return true;
390
+ }
391
+ if (fn.name && /^[A-Z]/.test(fn.name)) {
392
+ return true;
393
+ }
394
+ return false;
395
+ }
396
+
397
+ // libs/ui/src/universal/renderers/mdx.renderer.ts
398
+ import React5 from "react";
399
+ import { escapeHtml as escapeHtml2 } from "@frontmcp/uipack/utils";
400
+ function getMDXRuntime() {
401
+ if (typeof window !== "undefined" && window.MDXProvider) {
402
+ return { MDXProvider: window.MDXProvider };
403
+ }
404
+ return null;
405
+ }
406
+ function containsMdxSyntax(source) {
407
+ if (/<[A-Z][a-zA-Z]*/.test(source)) {
408
+ return true;
409
+ }
410
+ if (/\{[^}"']+\}/.test(source)) {
411
+ return true;
412
+ }
413
+ if (/^(import|export)\s/m.test(source)) {
414
+ return true;
415
+ }
416
+ if (/\s(className|onClick|onChange)=/.test(source)) {
417
+ return true;
418
+ }
419
+ return false;
420
+ }
421
+ var mdxRenderer = {
422
+ type: "mdx",
423
+ priority: 20,
424
+ // Higher than markdown, lower than React
425
+ canHandle(content) {
426
+ if (content.type === "mdx") {
427
+ return true;
428
+ }
429
+ if (typeof content.source === "string") {
430
+ const source = content.source;
431
+ const hasMarkdown = /^#{1,6}\s/m.test(source) || /^\*\s/m.test(source) || /^-\s/m.test(source) || /^\d+\.\s/m.test(source);
432
+ return hasMarkdown && containsMdxSyntax(source);
433
+ }
434
+ return false;
435
+ },
436
+ render(content, context) {
437
+ const source = content.source;
438
+ if (typeof source !== "string") {
439
+ return React5.createElement("div", { className: "frontmcp-error" }, "MDX renderer requires a string source");
440
+ }
441
+ const mdxRuntime = getMDXRuntime();
442
+ if (!mdxRuntime) {
443
+ console.warn("[FrontMCP] MDX runtime not available. Content will be displayed as-is.");
444
+ const escapedContent = escapeHtml2(source).replace(/\n/g, "<br>");
445
+ return React5.createElement(
446
+ "div",
447
+ { className: "frontmcp-mdx-fallback" },
448
+ React5.createElement(
449
+ "div",
450
+ {
451
+ key: "warning",
452
+ className: "frontmcp-warning bg-yellow-50 border border-yellow-200 rounded p-2 mb-4 text-sm text-yellow-800"
453
+ },
454
+ "MDX rendering is not available on this platform. Content is shown as raw text."
455
+ ),
456
+ React5.createElement("pre", {
457
+ key: "content",
458
+ className: "bg-gray-100 p-4 rounded overflow-auto",
459
+ dangerouslySetInnerHTML: { __html: escapedContent }
460
+ })
461
+ );
462
+ }
463
+ const components = {
464
+ ...context.components,
465
+ ...content.components
466
+ };
467
+ if (typeof content.compiledContent === "function") {
468
+ const CompiledContent = content.compiledContent;
469
+ return React5.createElement(
470
+ mdxRuntime.MDXProvider,
471
+ { components },
472
+ React5.createElement(CompiledContent, {
473
+ output: context.output,
474
+ input: context.input
475
+ })
476
+ );
477
+ }
478
+ console.warn("[FrontMCP] MDX content needs to be pre-compiled. Raw MDX string rendering is not supported.");
479
+ return React5.createElement(
480
+ "div",
481
+ { className: "frontmcp-mdx-uncompiled" },
482
+ React5.createElement("pre", { className: "bg-gray-100 p-4 rounded overflow-auto text-sm" }, source)
483
+ );
484
+ }
485
+ };
486
+ function isMdxSupported() {
487
+ return getMDXRuntime() !== null;
488
+ }
489
+ function createMdxRenderer(defaultComponents) {
490
+ return {
491
+ ...mdxRenderer,
492
+ render(content, context) {
493
+ const enhancedContext = {
494
+ ...context,
495
+ components: {
496
+ ...defaultComponents,
497
+ ...context.components
498
+ }
499
+ };
500
+ return mdxRenderer.render(content, enhancedContext);
501
+ }
502
+ };
503
+ }
504
+
505
+ // libs/ui/src/universal/renderers/index.ts
506
+ var RendererRegistry = class {
507
+ renderers = /* @__PURE__ */ new Map();
508
+ sortedRenderers = [];
509
+ constructor() {
510
+ this.register(htmlRenderer);
511
+ this.register(markdownRenderer);
512
+ this.register(reactRenderer);
513
+ this.register(mdxRenderer);
514
+ }
515
+ /**
516
+ * Register a renderer.
517
+ * Renderers are sorted by priority (highest first) for auto-detection.
518
+ */
519
+ register(renderer) {
520
+ this.renderers.set(renderer.type, renderer);
521
+ this.updateSortedList();
522
+ }
523
+ /**
524
+ * Unregister a renderer by type.
525
+ */
526
+ unregister(type) {
527
+ const removed = this.renderers.delete(type);
528
+ if (removed) {
529
+ this.updateSortedList();
530
+ }
531
+ return removed;
532
+ }
533
+ /**
534
+ * Get a renderer by type.
535
+ */
536
+ get(type) {
537
+ return this.renderers.get(type);
538
+ }
539
+ /**
540
+ * Check if a renderer type is registered.
541
+ */
542
+ has(type) {
543
+ return this.renderers.has(type);
544
+ }
545
+ /**
546
+ * Get all registered renderer types.
547
+ */
548
+ getTypes() {
549
+ return Array.from(this.renderers.keys());
550
+ }
551
+ /**
552
+ * Auto-detect the best renderer for content.
553
+ *
554
+ * Checks renderers in priority order (highest first).
555
+ * Falls back to HTML renderer if no match.
556
+ */
557
+ detect(content) {
558
+ if (content.type) {
559
+ const explicit = this.renderers.get(content.type);
560
+ if (explicit) {
561
+ return explicit;
562
+ }
563
+ }
564
+ for (const renderer of this.sortedRenderers) {
565
+ if (renderer.canHandle(content)) {
566
+ return renderer;
567
+ }
568
+ }
569
+ return htmlRenderer;
570
+ }
571
+ /**
572
+ * Render content using auto-detection.
573
+ */
574
+ render(content, context) {
575
+ const renderer = this.detect(content);
576
+ return renderer.render(content, context);
577
+ }
578
+ /**
579
+ * Render with a specific renderer type.
580
+ */
581
+ renderWith(type, content, context) {
582
+ const renderer = this.renderers.get(type);
583
+ if (!renderer) {
584
+ throw new Error(`Renderer '${type}' not registered`);
585
+ }
586
+ return renderer.render(content, context);
587
+ }
588
+ /**
589
+ * Get registry statistics.
590
+ */
591
+ getStats() {
592
+ return {
593
+ registeredTypes: this.getTypes(),
594
+ priorityOrder: this.sortedRenderers.map((r) => ({
595
+ type: r.type,
596
+ priority: r.priority
597
+ }))
598
+ };
599
+ }
600
+ /**
601
+ * Update the sorted renderer list by priority.
602
+ */
603
+ updateSortedList() {
604
+ this.sortedRenderers = Array.from(this.renderers.values()).sort((a, b) => b.priority - a.priority);
605
+ }
606
+ };
607
+ var rendererRegistry = new RendererRegistry();
608
+ function detectRenderer(content) {
609
+ return rendererRegistry.detect(content);
610
+ }
611
+ function renderContent(content, context) {
612
+ return rendererRegistry.render(content, context);
613
+ }
614
+ function createContent(source, options) {
615
+ return {
616
+ type: options?.type ?? detectContentType(source),
617
+ source,
618
+ props: options?.props,
619
+ components: options?.components
620
+ };
621
+ }
622
+
623
+ // libs/ui/src/universal/UniversalApp.tsx
624
+ import React6 from "react";
625
+ import { escapeHtml as escapeHtml3 } from "@frontmcp/uipack/utils";
626
+ function LoadingSpinner() {
627
+ return React6.createElement(
628
+ "div",
629
+ { className: "frontmcp-loading flex items-center justify-center min-h-[200px]" },
630
+ React6.createElement("div", {
631
+ className: "frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin"
632
+ })
633
+ );
634
+ }
635
+ function ErrorDisplay({ error }) {
636
+ return React6.createElement(
637
+ "div",
638
+ {
639
+ className: "frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800"
640
+ },
641
+ [
642
+ React6.createElement("div", { key: "title", className: "font-medium" }, "Error"),
643
+ React6.createElement("div", { key: "message", className: "text-sm mt-1" }, escapeHtml3(error))
644
+ ]
645
+ );
646
+ }
647
+ function EmptyState() {
648
+ return React6.createElement(
649
+ "div",
650
+ {
651
+ className: "frontmcp-empty text-gray-500 text-center py-8"
652
+ },
653
+ "No content to display"
654
+ );
655
+ }
656
+ function UniversalRenderer({
657
+ content,
658
+ state
659
+ }) {
660
+ const components = useComponents();
661
+ const context = {
662
+ output: state.output,
663
+ input: state.input,
664
+ components: {
665
+ ...components,
666
+ ...content.components
667
+ },
668
+ state
669
+ };
670
+ const rendered = renderContent(content, context);
671
+ return React6.createElement("div", { className: "frontmcp-content" }, rendered);
672
+ }
673
+ function UniversalApp({
674
+ content: contentOverride,
675
+ components,
676
+ fallback,
677
+ errorFallback: ErrorFallback = ErrorDisplay
678
+ }) {
679
+ const state = useFrontMCPStore();
680
+ if (state.loading) {
681
+ return fallback ? React6.createElement(React6.Fragment, null, fallback) : React6.createElement(LoadingSpinner, null);
682
+ }
683
+ if (state.error) {
684
+ return React6.createElement(ErrorFallback, { error: state.error });
685
+ }
686
+ const content = contentOverride ?? state.content;
687
+ if (!content) {
688
+ return React6.createElement(EmptyState, null);
689
+ }
690
+ if (components) {
691
+ return React6.createElement(
692
+ ComponentsProvider,
693
+ { components },
694
+ React6.createElement(UniversalRenderer, { content, state })
695
+ );
696
+ }
697
+ return React6.createElement(UniversalRenderer, { content, state });
698
+ }
699
+ function UniversalAppWithProvider({
700
+ initialState,
701
+ components,
702
+ ...appProps
703
+ }) {
704
+ return React6.createElement(
705
+ FrontMCPProvider,
706
+ { initialState },
707
+ components ? React6.createElement(ComponentsProvider, { components }, React6.createElement(UniversalApp, appProps)) : React6.createElement(UniversalApp, appProps)
708
+ );
709
+ }
710
+
711
+ // libs/ui/src/universal/runtime-builder.ts
712
+ function buildStoreRuntime() {
713
+ return `
714
+ // FrontMCP Store
715
+ (function() {
716
+ var state = {
717
+ toolName: null,
718
+ input: null,
719
+ output: null,
720
+ content: null,
721
+ structuredContent: null,
722
+ loading: false,
723
+ error: null
724
+ };
725
+
726
+ var listeners = new Set();
727
+
728
+ window.__frontmcp = {
729
+ // Store methods
730
+ getState: function() { return state; },
731
+ setState: function(partial) {
732
+ state = Object.assign({}, state, partial);
733
+ listeners.forEach(function(fn) { fn(); });
734
+ },
735
+ subscribe: function(fn) {
736
+ listeners.add(fn);
737
+ return function() { listeners.delete(fn); };
738
+ },
739
+ reset: function() {
740
+ state = {
741
+ toolName: null,
742
+ input: null,
743
+ output: null,
744
+ content: null,
745
+ structuredContent: null,
746
+ loading: false,
747
+ error: null
748
+ };
749
+ },
750
+
751
+ // Context (legacy support)
752
+ context: state,
753
+ setContext: function(ctx) {
754
+ this.setState(ctx);
755
+ }
756
+ };
757
+
758
+ // Hooks for React components
759
+ window.useFrontMCPStore = function() {
760
+ var store = window.__frontmcp;
761
+ return React.useSyncExternalStore(
762
+ store.subscribe,
763
+ store.getState,
764
+ store.getState
765
+ );
766
+ };
767
+
768
+ window.useToolOutput = function() {
769
+ return window.useFrontMCPStore().output;
770
+ };
771
+
772
+ window.useToolInput = function() {
773
+ return window.useFrontMCPStore().input;
774
+ };
775
+
776
+ window.useContent = function() {
777
+ return window.useFrontMCPStore().content;
778
+ };
779
+ })();
780
+ `;
781
+ }
782
+ function buildInlineMarkdownParser(options) {
783
+ const allowUnsafeLinks = options?.contentSecurity?.bypassSanitization || options?.contentSecurity?.allowUnsafeLinks;
784
+ return `
785
+ // Inline Markdown Parser
786
+ (function() {
787
+ // XSS protection settings (configured at build time)
788
+ var __allowUnsafeLinks = ${allowUnsafeLinks ? "true" : "false"};
789
+
790
+ // URL scheme validation to prevent XSS via javascript: URLs
791
+ function isSafeUrl(url) {
792
+ // If unsafe links are allowed, all URLs are considered safe
793
+ if (__allowUnsafeLinks) return true;
794
+ if (!url) return false;
795
+ var lower = url.toLowerCase().trim();
796
+ return lower.startsWith('http://') ||
797
+ lower.startsWith('https://') ||
798
+ lower.startsWith('/') ||
799
+ lower.startsWith('#') ||
800
+ lower.startsWith('mailto:');
801
+ }
802
+
803
+ function parseMarkdown(md) {
804
+ var html = md;
805
+ // Escape HTML
806
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
807
+ // Headers
808
+ html = html.replace(/^######\\s+(.*)$/gm, '<h6>$1</h6>');
809
+ html = html.replace(/^#####\\s+(.*)$/gm, '<h5>$1</h5>');
810
+ html = html.replace(/^####\\s+(.*)$/gm, '<h4>$1</h4>');
811
+ html = html.replace(/^###\\s+(.*)$/gm, '<h3>$1</h3>');
812
+ html = html.replace(/^##\\s+(.*)$/gm, '<h2>$1</h2>');
813
+ html = html.replace(/^#\\s+(.*)$/gm, '<h1>$1</h1>');
814
+ // Bold and italic
815
+ html = html.replace(/\\*\\*\\*(.+?)\\*\\*\\*/g, '<strong><em>$1</em></strong>');
816
+ html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');
817
+ html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');
818
+ // Inline code
819
+ html = html.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
820
+ // Links - validate URL scheme to prevent XSS (unless bypassed)
821
+ html = html.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, function(match, text, url) {
822
+ return isSafeUrl(url) ? '<a href="' + url + '">' + text + '</a>' : text;
823
+ });
824
+ // Lists
825
+ html = html.replace(/^[-*]\\s+(.*)$/gm, '<li>$1</li>');
826
+ // Paragraphs
827
+ html = html.replace(/\\n\\n+/g, '</p><p>');
828
+ html = '<p>' + html + '</p>';
829
+ return html;
830
+ }
831
+
832
+ window.__frontmcp.parseMarkdown = parseMarkdown;
833
+
834
+ // Simple ReactMarkdown replacement
835
+ window.ReactMarkdown = function(props) {
836
+ var html = parseMarkdown(props.children || '');
837
+ return React.createElement('div', {
838
+ className: 'frontmcp-markdown prose',
839
+ dangerouslySetInnerHTML: { __html: html }
840
+ });
841
+ };
842
+ })();
843
+ `;
844
+ }
845
+ function buildRenderersRuntime(options) {
846
+ const bypassSanitization = options?.contentSecurity?.bypassSanitization;
847
+ const allowInlineScripts = bypassSanitization || options?.contentSecurity?.allowInlineScripts;
848
+ return `
849
+ // Universal Renderers
850
+ (function() {
851
+ var renderers = {};
852
+
853
+ // XSS protection settings (configured at build time)
854
+ var __allowInlineScripts = ${allowInlineScripts ? "true" : "false"};
855
+
856
+ // HTML Renderer
857
+ renderers.html = {
858
+ type: 'html',
859
+ priority: 0,
860
+ canHandle: function(c) { return c.type === 'html'; },
861
+ render: function(c, ctx) {
862
+ var html = c.source;
863
+ // Apply XSS protection unless bypassed
864
+ if (!__allowInlineScripts) {
865
+ // Remove script tags and event handlers
866
+ html = html.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');
867
+ html = html.replace(/\\s+on\\w+\\s*=/gi, ' data-removed-handler=');
868
+ }
869
+ return React.createElement('div', {
870
+ className: 'frontmcp-html-content',
871
+ dangerouslySetInnerHTML: { __html: html }
872
+ });
873
+ }
874
+ };
875
+
876
+ // Markdown Renderer
877
+ renderers.markdown = {
878
+ type: 'markdown',
879
+ priority: 10,
880
+ canHandle: function(c) {
881
+ if (c.type === 'markdown') return true;
882
+ if (typeof c.source !== 'string') return false;
883
+ var s = c.source;
884
+ return /^#{1,6}\\s/m.test(s) || /^[-*]\\s/m.test(s) || /\\*\\*[^*]+\\*\\*/.test(s);
885
+ },
886
+ render: function(c, ctx) {
887
+ if (window.ReactMarkdown) {
888
+ return React.createElement(window.ReactMarkdown, {
889
+ children: c.source,
890
+ components: Object.assign({}, ctx.components, c.components)
891
+ });
892
+ }
893
+ // Fallback to inline parser
894
+ var html = window.__frontmcp.parseMarkdown ? window.__frontmcp.parseMarkdown(c.source) : c.source;
895
+ return React.createElement('div', {
896
+ className: 'frontmcp-markdown prose',
897
+ dangerouslySetInnerHTML: { __html: html }
898
+ });
899
+ }
900
+ };
901
+
902
+ // React Renderer
903
+ renderers.react = {
904
+ type: 'react',
905
+ priority: 30,
906
+ canHandle: function(c) { return c.type === 'react' || typeof c.source === 'function'; },
907
+ render: function(c, ctx) {
908
+ var Component = c.source;
909
+ var props = Object.assign({
910
+ output: ctx.output,
911
+ input: ctx.input,
912
+ state: ctx.state
913
+ }, c.props);
914
+ return React.createElement(Component, props);
915
+ }
916
+ };
917
+
918
+ // MDX Renderer
919
+ renderers.mdx = {
920
+ type: 'mdx',
921
+ priority: 20,
922
+ canHandle: function(c) {
923
+ if (c.type === 'mdx') return true;
924
+ if (typeof c.source !== 'string') return false;
925
+ var s = c.source;
926
+ return /<[A-Z][a-zA-Z]*/.test(s) && /^#{1,6}\\s/m.test(s);
927
+ },
928
+ render: function(c, ctx) {
929
+ // MDX requires pre-compilation, fallback to showing source
930
+ if (typeof c.compiledContent === 'function') {
931
+ var MDXContent = c.compiledContent;
932
+ return React.createElement(MDXContent, {
933
+ output: ctx.output,
934
+ input: ctx.input,
935
+ components: Object.assign({}, ctx.components, c.components)
936
+ });
937
+ }
938
+ // Show warning
939
+ return React.createElement('div', { className: 'frontmcp-mdx-fallback' }, [
940
+ React.createElement('div', {
941
+ key: 'warn',
942
+ className: 'bg-yellow-50 border border-yellow-200 rounded p-2 mb-2 text-sm text-yellow-800'
943
+ }, 'MDX requires pre-compilation. Showing raw content.'),
944
+ React.createElement('pre', {
945
+ key: 'pre',
946
+ className: 'bg-gray-100 p-4 rounded text-sm overflow-auto'
947
+ }, c.source)
948
+ ]);
949
+ }
950
+ };
951
+
952
+ // Sorted by priority
953
+ var sortedRenderers = [renderers.react, renderers.mdx, renderers.markdown, renderers.html];
954
+
955
+ // Detect renderer
956
+ window.__frontmcp.detectRenderer = function(content) {
957
+ if (content.type && renderers[content.type]) {
958
+ return renderers[content.type];
959
+ }
960
+ for (var i = 0; i < sortedRenderers.length; i++) {
961
+ if (sortedRenderers[i].canHandle(content)) {
962
+ return sortedRenderers[i];
963
+ }
964
+ }
965
+ return renderers.html;
966
+ };
967
+
968
+ // Render content
969
+ window.__frontmcp.renderContent = function(content, context) {
970
+ var renderer = window.__frontmcp.detectRenderer(content);
971
+ return renderer.render(content, context);
972
+ };
973
+
974
+ window.__frontmcp.renderers = renderers;
975
+ })();
976
+ `;
977
+ }
978
+ function buildUniversalAppRuntime() {
979
+ return `
980
+ // Universal App Component
981
+ (function() {
982
+ var LoadingSpinner = function() {
983
+ return React.createElement('div', {
984
+ className: 'frontmcp-loading flex items-center justify-center min-h-[200px]'
985
+ }, React.createElement('div', {
986
+ className: 'frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin'
987
+ }));
988
+ };
989
+
990
+ var ErrorDisplay = function(props) {
991
+ return React.createElement('div', {
992
+ className: 'frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800'
993
+ }, [
994
+ React.createElement('div', { key: 'title', className: 'font-medium' }, 'Error'),
995
+ React.createElement('div', { key: 'msg', className: 'text-sm mt-1' }, props.error)
996
+ ]);
997
+ };
998
+
999
+ var EmptyState = function() {
1000
+ return React.createElement('div', {
1001
+ className: 'frontmcp-empty text-gray-500 text-center py-8'
1002
+ }, 'No content to display');
1003
+ };
1004
+
1005
+ window.__frontmcp.UniversalApp = function(props) {
1006
+ var state = window.useFrontMCPStore();
1007
+
1008
+ if (state.loading) {
1009
+ return props.fallback || React.createElement(LoadingSpinner);
1010
+ }
1011
+
1012
+ if (state.error) {
1013
+ var ErrorComp = props.errorFallback || ErrorDisplay;
1014
+ return React.createElement(ErrorComp, { error: state.error });
1015
+ }
1016
+
1017
+ var content = props.content || state.content;
1018
+
1019
+ if (!content) {
1020
+ return React.createElement(EmptyState);
1021
+ }
1022
+
1023
+ var context = {
1024
+ output: state.output,
1025
+ input: state.input,
1026
+ state: state,
1027
+ components: props.components || {}
1028
+ };
1029
+
1030
+ var rendered = window.__frontmcp.renderContent(content, context);
1031
+ return React.createElement('div', { className: 'frontmcp-content' }, rendered);
1032
+ };
1033
+
1034
+ window.__frontmcp.LoadingSpinner = LoadingSpinner;
1035
+ window.__frontmcp.ErrorDisplay = ErrorDisplay;
1036
+ window.__frontmcp.EmptyState = EmptyState;
1037
+ })();
1038
+ `;
1039
+ }
1040
+ function buildCdnImports(options) {
1041
+ const parts = [];
1042
+ if (options.cdnType === "esm") {
1043
+ if (options.includeMarkdown) {
1044
+ parts.push(`
1045
+ <script type="module">
1046
+ import ReactMarkdown from '${UNIVERSAL_CDN.esm.reactMarkdown}';
1047
+ window.ReactMarkdown = ReactMarkdown;
1048
+ </script>`);
1049
+ }
1050
+ if (options.includeMdx) {
1051
+ parts.push(`
1052
+ <script type="module">
1053
+ import { MDXProvider } from '${UNIVERSAL_CDN.esm.mdxReact}';
1054
+ window.MDXProvider = MDXProvider;
1055
+ </script>`);
1056
+ }
1057
+ }
1058
+ return parts.join("\n");
1059
+ }
1060
+ function buildUniversalRuntime(options) {
1061
+ const parts = [];
1062
+ parts.push(buildStoreRuntime());
1063
+ if (options.cdnType === "umd" || options.includeMarkdown) {
1064
+ parts.push(buildInlineMarkdownParser(options));
1065
+ }
1066
+ parts.push(buildRenderersRuntime(options));
1067
+ parts.push(buildUniversalAppRuntime());
1068
+ if (options.customComponents) {
1069
+ parts.push(`
1070
+ // Custom Components
1071
+ (function() {
1072
+ ${options.customComponents}
1073
+ })();
1074
+ `);
1075
+ }
1076
+ let script = parts.join("\n");
1077
+ if (options.minify) {
1078
+ script = script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1079
+ }
1080
+ return {
1081
+ script,
1082
+ cdnImports: buildCdnImports(options),
1083
+ size: script.length
1084
+ };
1085
+ }
1086
+ function buildMinimalRuntime(options) {
1087
+ let script = buildStoreRuntime();
1088
+ if (options.minify) {
1089
+ script = script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1090
+ }
1091
+ return script;
1092
+ }
1093
+
1094
+ // libs/ui/src/universal/cached-runtime.ts
1095
+ var RUNTIME_PLACEHOLDERS = {
1096
+ /** Placeholder for transpiled component code */
1097
+ COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/",
1098
+ /** Placeholder for data injection */
1099
+ DATA_INJECTION: "/*__FRONTMCP_DATA_INJECTION__*/",
1100
+ /** Placeholder for custom components */
1101
+ CUSTOM_COMPONENTS: "/*__FRONTMCP_CUSTOM_COMPONENTS__*/"
1102
+ };
1103
+ var runtimeCache = /* @__PURE__ */ new Map();
1104
+ var DEFAULT_CACHE_CONFIG = {
1105
+ maxEntries: 10,
1106
+ ttl: 0
1107
+ // Forever by default
1108
+ };
1109
+ function generateCacheKey(options) {
1110
+ const securityKey = options.contentSecurity ? [
1111
+ options.contentSecurity.allowUnsafeLinks ? "unsafeLinks" : "",
1112
+ options.contentSecurity.allowInlineScripts ? "unsafeScripts" : "",
1113
+ options.contentSecurity.bypassSanitization ? "bypass" : ""
1114
+ ].filter(Boolean).join("+") || "secure" : "secure";
1115
+ return [
1116
+ options.cdnType,
1117
+ options.includeMarkdown ? "md" : "",
1118
+ options.includeMdx ? "mdx" : "",
1119
+ options.minify ? "min" : "",
1120
+ securityKey
1121
+ ].filter(Boolean).join(":");
1122
+ }
1123
+ function buildStoreRuntime2() {
1124
+ return `
1125
+ // FrontMCP Store (Vendor)
1126
+ (function() {
1127
+ var state = {
1128
+ toolName: null,
1129
+ input: null,
1130
+ output: null,
1131
+ content: null,
1132
+ structuredContent: null,
1133
+ loading: false,
1134
+ error: null
1135
+ };
1136
+
1137
+ var listeners = new Set();
1138
+
1139
+ window.__frontmcp = {
1140
+ getState: function() { return state; },
1141
+ setState: function(partial) {
1142
+ state = Object.assign({}, state, partial);
1143
+ listeners.forEach(function(fn) { fn(); });
1144
+ },
1145
+ subscribe: function(fn) {
1146
+ listeners.add(fn);
1147
+ return function() { listeners.delete(fn); };
1148
+ },
1149
+ reset: function() {
1150
+ state = {
1151
+ toolName: null,
1152
+ input: null,
1153
+ output: null,
1154
+ content: null,
1155
+ structuredContent: null,
1156
+ loading: false,
1157
+ error: null
1158
+ };
1159
+ },
1160
+ context: state,
1161
+ setContext: function(ctx) {
1162
+ this.setState(ctx);
1163
+ }
1164
+ };
1165
+
1166
+ // React hooks
1167
+ window.useFrontMCPStore = function() {
1168
+ var store = window.__frontmcp;
1169
+ return React.useSyncExternalStore(
1170
+ store.subscribe,
1171
+ store.getState,
1172
+ store.getState
1173
+ );
1174
+ };
1175
+
1176
+ window.useToolOutput = function() {
1177
+ return window.useFrontMCPStore().output;
1178
+ };
1179
+
1180
+ window.useToolInput = function() {
1181
+ return window.useFrontMCPStore().input;
1182
+ };
1183
+
1184
+ window.useContent = function() {
1185
+ return window.useFrontMCPStore().content;
1186
+ };
1187
+ })();
1188
+ `;
1189
+ }
1190
+ function buildRequireShim() {
1191
+ return `
1192
+ // Module Require Shim (Vendor)
1193
+ (function() {
1194
+ window.__moduleCache = {};
1195
+ window.require = function(moduleName) {
1196
+ if (window.__moduleCache[moduleName]) {
1197
+ return window.__moduleCache[moduleName];
1198
+ }
1199
+
1200
+ var moduleMap = {
1201
+ 'react': function() { return window.React; },
1202
+ 'react-dom': function() { return window.ReactDOM; },
1203
+ 'react-dom/client': function() { return window.ReactDOM; },
1204
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
1205
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
1206
+ '@frontmcp/ui': function() { return window.frontmcp_ui_namespaceObject; },
1207
+ '@frontmcp/ui/react': function() { return window.frontmcp_ui_namespaceObject; }
1208
+ };
1209
+
1210
+ var resolver = moduleMap[moduleName];
1211
+ if (resolver) {
1212
+ var mod = resolver();
1213
+ window.__moduleCache[moduleName] = mod;
1214
+ return mod;
1215
+ }
1216
+
1217
+ console.warn('[FrontMCP] Unknown module:', moduleName);
1218
+ return {};
1219
+ };
1220
+ })();
1221
+ `;
1222
+ }
1223
+ function buildInlineMarkdownParser2(options) {
1224
+ const allowUnsafeLinks = options?.contentSecurity?.bypassSanitization || options?.contentSecurity?.allowUnsafeLinks;
1225
+ return `
1226
+ // Inline Markdown Parser (Vendor)
1227
+ (function() {
1228
+ // XSS protection settings (configured at build time)
1229
+ // Set to true if contentSecurity.allowUnsafeLinks or bypassSanitization is enabled
1230
+ var __allowUnsafeLinks = ${allowUnsafeLinks ? "true" : "false"};
1231
+
1232
+ // URL scheme validation to prevent XSS via javascript: URLs
1233
+ function isSafeUrl(url) {
1234
+ // If unsafe links are explicitly allowed, skip validation
1235
+ if (__allowUnsafeLinks) return true;
1236
+ if (!url) return false;
1237
+ var lower = url.toLowerCase().trim();
1238
+ return lower.startsWith('http://') ||
1239
+ lower.startsWith('https://') ||
1240
+ lower.startsWith('/') ||
1241
+ lower.startsWith('#') ||
1242
+ lower.startsWith('mailto:');
1243
+ }
1244
+
1245
+ function parseMarkdown(md) {
1246
+ var html = md;
1247
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1248
+ html = html.replace(/^######\\s+(.*)$/gm, '<h6>$1</h6>');
1249
+ html = html.replace(/^#####\\s+(.*)$/gm, '<h5>$1</h5>');
1250
+ html = html.replace(/^####\\s+(.*)$/gm, '<h4>$1</h4>');
1251
+ html = html.replace(/^###\\s+(.*)$/gm, '<h3>$1</h3>');
1252
+ html = html.replace(/^##\\s+(.*)$/gm, '<h2>$1</h2>');
1253
+ html = html.replace(/^#\\s+(.*)$/gm, '<h1>$1</h1>');
1254
+ html = html.replace(/\\*\\*\\*(.+?)\\*\\*\\*/g, '<strong><em>$1</em></strong>');
1255
+ html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');
1256
+ html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');
1257
+ html = html.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
1258
+ // Links - validate URL scheme to prevent XSS (unless bypassed)
1259
+ html = html.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, function(match, text, url) {
1260
+ return isSafeUrl(url) ? '<a href="' + url + '">' + text + '</a>' : text;
1261
+ });
1262
+ html = html.replace(/^[-*]\\s+(.*)$/gm, '<li>$1</li>');
1263
+ html = html.replace(/\\n\\n+/g, '</p><p>');
1264
+ html = '<p>' + html + '</p>';
1265
+ return html;
1266
+ }
1267
+
1268
+ window.__frontmcp.parseMarkdown = parseMarkdown;
1269
+
1270
+ window.ReactMarkdown = function(props) {
1271
+ var html = parseMarkdown(props.children || '');
1272
+ return React.createElement('div', {
1273
+ className: 'frontmcp-markdown prose',
1274
+ dangerouslySetInnerHTML: { __html: html }
1275
+ });
1276
+ };
1277
+ })();
1278
+ `;
1279
+ }
1280
+ function buildRenderersRuntime2(options) {
1281
+ const bypassSanitization = options?.contentSecurity?.bypassSanitization;
1282
+ const allowInlineScripts = bypassSanitization || options?.contentSecurity?.allowInlineScripts;
1283
+ return `
1284
+ // Universal Renderers (Vendor)
1285
+ (function() {
1286
+ var renderers = {};
1287
+
1288
+ // XSS protection settings (configured at build time)
1289
+ // Set to true if contentSecurity.allowInlineScripts or bypassSanitization is enabled
1290
+ var __allowInlineScripts = ${allowInlineScripts ? "true" : "false"};
1291
+
1292
+ renderers.html = {
1293
+ type: 'html',
1294
+ priority: 0,
1295
+ canHandle: function(c) { return c.type === 'html'; },
1296
+ render: function(c, ctx) {
1297
+ var html = c.source;
1298
+ // Apply XSS protection unless bypassed
1299
+ if (!__allowInlineScripts) {
1300
+ // Remove script tags and event handlers to prevent XSS
1301
+ html = html.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');
1302
+ html = html.replace(/\\s+on\\w+\\s*=/gi, ' data-removed-handler=');
1303
+ }
1304
+ return React.createElement('div', {
1305
+ className: 'frontmcp-html-content',
1306
+ dangerouslySetInnerHTML: { __html: html }
1307
+ });
1308
+ }
1309
+ };
1310
+
1311
+ renderers.markdown = {
1312
+ type: 'markdown',
1313
+ priority: 10,
1314
+ canHandle: function(c) {
1315
+ if (c.type === 'markdown') return true;
1316
+ if (typeof c.source !== 'string') return false;
1317
+ var s = c.source;
1318
+ return /^#{1,6}\\s/m.test(s) || /^[-*]\\s/m.test(s) || /\\*\\*[^*]+\\*\\*/.test(s);
1319
+ },
1320
+ render: function(c, ctx) {
1321
+ if (window.ReactMarkdown) {
1322
+ return React.createElement(window.ReactMarkdown, {
1323
+ children: c.source,
1324
+ components: Object.assign({}, ctx.components, c.components)
1325
+ });
1326
+ }
1327
+ var html = window.__frontmcp.parseMarkdown ? window.__frontmcp.parseMarkdown(c.source) : c.source;
1328
+ return React.createElement('div', {
1329
+ className: 'frontmcp-markdown prose',
1330
+ dangerouslySetInnerHTML: { __html: html }
1331
+ });
1332
+ }
1333
+ };
1334
+
1335
+ renderers.react = {
1336
+ type: 'react',
1337
+ priority: 30,
1338
+ canHandle: function(c) { return c.type === 'react' || typeof c.source === 'function'; },
1339
+ render: function(c, ctx) {
1340
+ var Component = c.source;
1341
+ var props = Object.assign({
1342
+ output: ctx.output,
1343
+ input: ctx.input,
1344
+ state: ctx.state,
1345
+ data: ctx.output // Alias for convenience
1346
+ }, c.props);
1347
+ return React.createElement(Component, props);
1348
+ }
1349
+ };
1350
+
1351
+ renderers.mdx = {
1352
+ type: 'mdx',
1353
+ priority: 20,
1354
+ canHandle: function(c) {
1355
+ if (c.type === 'mdx') return true;
1356
+ if (typeof c.source !== 'string') return false;
1357
+ var s = c.source;
1358
+ return /<[A-Z][a-zA-Z]*/.test(s) && /^#{1,6}\\s/m.test(s);
1359
+ },
1360
+ render: function(c, ctx) {
1361
+ if (typeof c.compiledContent === 'function') {
1362
+ var MDXContent = c.compiledContent;
1363
+ return React.createElement(MDXContent, {
1364
+ output: ctx.output,
1365
+ input: ctx.input,
1366
+ components: Object.assign({}, ctx.components, c.components)
1367
+ });
1368
+ }
1369
+ return React.createElement('div', { className: 'frontmcp-mdx-fallback' }, [
1370
+ React.createElement('div', {
1371
+ key: 'warn',
1372
+ className: 'bg-yellow-50 border border-yellow-200 rounded p-2 mb-2 text-sm text-yellow-800'
1373
+ }, 'MDX requires pre-compilation. Showing raw content.'),
1374
+ React.createElement('pre', {
1375
+ key: 'pre',
1376
+ className: 'bg-gray-100 p-4 rounded text-sm overflow-auto'
1377
+ }, c.source)
1378
+ ]);
1379
+ }
1380
+ };
1381
+
1382
+ var sortedRenderers = [renderers.react, renderers.mdx, renderers.markdown, renderers.html];
1383
+
1384
+ window.__frontmcp.detectRenderer = function(content) {
1385
+ if (content.type && renderers[content.type]) {
1386
+ return renderers[content.type];
1387
+ }
1388
+ for (var i = 0; i < sortedRenderers.length; i++) {
1389
+ if (sortedRenderers[i].canHandle(content)) {
1390
+ return sortedRenderers[i];
1391
+ }
1392
+ }
1393
+ return renderers.html;
1394
+ };
1395
+
1396
+ window.__frontmcp.renderContent = function(content, context) {
1397
+ var renderer = window.__frontmcp.detectRenderer(content);
1398
+ return renderer.render(content, context);
1399
+ };
1400
+
1401
+ window.__frontmcp.renderers = renderers;
1402
+ })();
1403
+ `;
1404
+ }
1405
+ function buildUIComponentsRuntime() {
1406
+ return `
1407
+ // UI Components (Vendor)
1408
+ (function() {
1409
+ window.Card = function(props) {
1410
+ var children = props.children;
1411
+ var title = props.title;
1412
+ var className = props.className || '';
1413
+ return React.createElement('div', {
1414
+ className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
1415
+ }, [
1416
+ title && React.createElement('div', {
1417
+ key: 'header',
1418
+ className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
1419
+ }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
1420
+ React.createElement('div', { key: 'body', className: 'p-4' }, children)
1421
+ ]);
1422
+ };
1423
+
1424
+ window.Badge = function(props) {
1425
+ var children = props.children;
1426
+ var variant = props.variant || 'default';
1427
+ var variantClasses = {
1428
+ default: 'bg-gray-100 text-gray-800',
1429
+ success: 'bg-green-100 text-green-800',
1430
+ warning: 'bg-yellow-100 text-yellow-800',
1431
+ error: 'bg-red-100 text-red-800',
1432
+ info: 'bg-blue-100 text-blue-800'
1433
+ };
1434
+ return React.createElement('span', {
1435
+ className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
1436
+ }, children);
1437
+ };
1438
+
1439
+ window.Button = function(props) {
1440
+ var children = props.children;
1441
+ var variant = props.variant || 'primary';
1442
+ var onClick = props.onClick;
1443
+ var disabled = props.disabled;
1444
+ var variantClasses = {
1445
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
1446
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
1447
+ outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
1448
+ danger: 'bg-red-600 text-white hover:bg-red-700'
1449
+ };
1450
+ return React.createElement('button', {
1451
+ className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
1452
+ (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
1453
+ (variantClasses[variant] || variantClasses.primary),
1454
+ onClick: onClick,
1455
+ disabled: disabled
1456
+ }, children);
1457
+ };
1458
+
1459
+ // Export to namespace
1460
+ window.frontmcp_ui_namespaceObject = Object.assign({}, window.React || {}, {
1461
+ useToolOutput: window.useToolOutput,
1462
+ useToolInput: window.useToolInput,
1463
+ useMcpBridgeContext: function() { return window.__frontmcp.context; },
1464
+ useCallTool: function() { return function() { return Promise.resolve(null); }; },
1465
+ Card: window.Card,
1466
+ Badge: window.Badge,
1467
+ Button: window.Button
1468
+ });
1469
+ })();
1470
+ `;
1471
+ }
1472
+ function buildUniversalAppRuntime2() {
1473
+ return `
1474
+ // Universal App (Vendor)
1475
+ (function() {
1476
+ var LoadingSpinner = function() {
1477
+ return React.createElement('div', {
1478
+ className: 'frontmcp-loading flex items-center justify-center min-h-[200px]'
1479
+ }, React.createElement('div', {
1480
+ className: 'frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin'
1481
+ }));
1482
+ };
1483
+
1484
+ var ErrorDisplay = function(props) {
1485
+ return React.createElement('div', {
1486
+ className: 'frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800'
1487
+ }, [
1488
+ React.createElement('div', { key: 'title', className: 'font-medium' }, 'Error'),
1489
+ React.createElement('div', { key: 'msg', className: 'text-sm mt-1' }, props.error)
1490
+ ]);
1491
+ };
1492
+
1493
+ var EmptyState = function() {
1494
+ return React.createElement('div', {
1495
+ className: 'frontmcp-empty text-gray-500 text-center py-8'
1496
+ }, 'No content to display');
1497
+ };
1498
+
1499
+ window.__frontmcp.UniversalApp = function(props) {
1500
+ var state = window.useFrontMCPStore();
1501
+
1502
+ if (state.loading) {
1503
+ return props.fallback || React.createElement(LoadingSpinner);
1504
+ }
1505
+
1506
+ if (state.error) {
1507
+ var ErrorComp = props.errorFallback || ErrorDisplay;
1508
+ return React.createElement(ErrorComp, { error: state.error });
1509
+ }
1510
+
1511
+ var content = props.content || state.content;
1512
+
1513
+ if (!content) {
1514
+ return React.createElement(EmptyState);
1515
+ }
1516
+
1517
+ var context = {
1518
+ output: state.output,
1519
+ input: state.input,
1520
+ state: state,
1521
+ components: props.components || {}
1522
+ };
1523
+
1524
+ var rendered = window.__frontmcp.renderContent(content, context);
1525
+ return React.createElement('div', { className: 'frontmcp-content' }, rendered);
1526
+ };
1527
+
1528
+ window.__frontmcp.LoadingSpinner = LoadingSpinner;
1529
+ window.__frontmcp.ErrorDisplay = ErrorDisplay;
1530
+ window.__frontmcp.EmptyState = EmptyState;
1531
+ })();
1532
+ `;
1533
+ }
1534
+ function buildComponentWrapper() {
1535
+ return `
1536
+ // Component Execution (App Chunk)
1537
+ (function() {
1538
+ ${RUNTIME_PLACEHOLDERS.COMPONENT_CODE}
1539
+ })();
1540
+ `;
1541
+ }
1542
+ function buildDataInjectionWrapper() {
1543
+ return `
1544
+ // Data Injection (App Chunk)
1545
+ (function() {
1546
+ ${RUNTIME_PLACEHOLDERS.DATA_INJECTION}
1547
+ })();
1548
+ `;
1549
+ }
1550
+ function buildCustomComponentsWrapper() {
1551
+ return `
1552
+ // Custom Components (App Chunk)
1553
+ (function() {
1554
+ ${RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS}
1555
+ })();
1556
+ `;
1557
+ }
1558
+ function buildCdnImports2(options) {
1559
+ const parts = [];
1560
+ if (options.cdnType === "esm") {
1561
+ if (options.includeMarkdown) {
1562
+ parts.push(`
1563
+ <script type="module">
1564
+ import ReactMarkdown from '${UNIVERSAL_CDN.esm.reactMarkdown}';
1565
+ window.ReactMarkdown = ReactMarkdown;
1566
+ </script>`);
1567
+ }
1568
+ if (options.includeMdx) {
1569
+ parts.push(`
1570
+ <script type="module">
1571
+ import { MDXProvider } from '${UNIVERSAL_CDN.esm.mdxReact}';
1572
+ window.MDXProvider = MDXProvider;
1573
+ </script>`);
1574
+ }
1575
+ }
1576
+ return parts.join("\n");
1577
+ }
1578
+ function getCachedRuntime(options, config = {}) {
1579
+ const cacheKey = generateCacheKey(options);
1580
+ const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...config };
1581
+ const cached = runtimeCache.get(cacheKey);
1582
+ if (cached) {
1583
+ if (cacheConfig.ttl === 0 || Date.now() - cached.cachedAt < cacheConfig.ttl) {
1584
+ return {
1585
+ vendorScript: cached.script,
1586
+ appTemplate: buildAppTemplate(),
1587
+ cdnImports: cached.cdnImports,
1588
+ vendorSize: cached.size,
1589
+ cached: true,
1590
+ cacheKey
1591
+ };
1592
+ }
1593
+ runtimeCache.delete(cacheKey);
1594
+ }
1595
+ const vendorParts = [buildStoreRuntime2(), buildRequireShim()];
1596
+ if (options.cdnType === "umd" || options.includeMarkdown) {
1597
+ vendorParts.push(buildInlineMarkdownParser2(options));
1598
+ }
1599
+ vendorParts.push(buildRenderersRuntime2(options));
1600
+ vendorParts.push(buildUIComponentsRuntime());
1601
+ vendorParts.push(buildUniversalAppRuntime2());
1602
+ let vendorScript = vendorParts.join("\n");
1603
+ if (options.minify) {
1604
+ vendorScript = minifyScript(vendorScript);
1605
+ }
1606
+ const cdnImports = buildCdnImports2(options);
1607
+ const entry = {
1608
+ script: vendorScript,
1609
+ cdnImports,
1610
+ size: vendorScript.length,
1611
+ cacheKey,
1612
+ cachedAt: Date.now()
1613
+ };
1614
+ if (runtimeCache.size >= cacheConfig.maxEntries) {
1615
+ const oldestKey = runtimeCache.keys().next().value;
1616
+ if (oldestKey) {
1617
+ runtimeCache.delete(oldestKey);
1618
+ }
1619
+ }
1620
+ runtimeCache.set(cacheKey, entry);
1621
+ return {
1622
+ vendorScript,
1623
+ appTemplate: buildAppTemplate(),
1624
+ cdnImports,
1625
+ vendorSize: vendorScript.length,
1626
+ cached: false,
1627
+ cacheKey
1628
+ };
1629
+ }
1630
+ function buildAppTemplate() {
1631
+ return [buildCustomComponentsWrapper(), buildComponentWrapper(), buildDataInjectionWrapper()].join("\n");
1632
+ }
1633
+ function minifyScript(script) {
1634
+ return script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1635
+ }
1636
+ function clearRuntimeCache() {
1637
+ runtimeCache.clear();
1638
+ }
1639
+ function getRuntimeCacheStats() {
1640
+ let totalSize = 0;
1641
+ const keys = [];
1642
+ for (const [key, entry] of runtimeCache) {
1643
+ keys.push(key);
1644
+ totalSize += entry.size;
1645
+ }
1646
+ return {
1647
+ entries: runtimeCache.size,
1648
+ totalSize,
1649
+ keys
1650
+ };
1651
+ }
1652
+ function buildAppScript(appTemplate, componentCode, dataInjection, customComponents = "") {
1653
+ return appTemplate.replace(RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS, customComponents || "// No custom components").replace(RUNTIME_PLACEHOLDERS.COMPONENT_CODE, componentCode || "// No component code").replace(RUNTIME_PLACEHOLDERS.DATA_INJECTION, dataInjection);
1654
+ }
1655
+ function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
1656
+ const safeJson = (value) => {
1657
+ try {
1658
+ return JSON.stringify(value);
1659
+ } catch {
1660
+ return "null";
1661
+ }
1662
+ };
1663
+ if (hasComponent) {
1664
+ return `
1665
+ window.__frontmcp.setState({
1666
+ toolName: ${safeJson(toolName)},
1667
+ input: ${safeJson(input ?? null)},
1668
+ output: ${safeJson(output ?? null)},
1669
+ structuredContent: ${safeJson(structuredContent ?? null)},
1670
+ content: {
1671
+ type: 'react',
1672
+ source: window.__frontmcp_component
1673
+ },
1674
+ loading: false,
1675
+ error: null
1676
+ });`;
1677
+ }
1678
+ return `
1679
+ window.__frontmcp.setState({
1680
+ toolName: ${safeJson(toolName)},
1681
+ input: ${safeJson(input ?? null)},
1682
+ output: ${safeJson(output ?? null)},
1683
+ structuredContent: ${safeJson(structuredContent ?? null)},
1684
+ content: {
1685
+ type: ${safeJson(contentType)},
1686
+ source: ${safeJson(source)}
1687
+ },
1688
+ loading: false,
1689
+ error: null
1690
+ });`;
1691
+ }
1692
+ function buildComponentCode(transpiledCode) {
1693
+ return `
1694
+ // CommonJS module shim
1695
+ var module = { exports: {} };
1696
+ var exports = module.exports;
1697
+
1698
+ // Execute transpiled component
1699
+ ${transpiledCode}
1700
+
1701
+ // Capture component
1702
+ window.__frontmcp_component = module.exports.default || module.exports;`;
1703
+ }
1704
+ export {
1705
+ ComponentsProvider,
1706
+ DEFAULT_FRONTMCP_STATE,
1707
+ EmptyState,
1708
+ ErrorDisplay,
1709
+ FrontMCPProvider,
1710
+ LoadingSpinner,
1711
+ RUNTIME_PLACEHOLDERS,
1712
+ RendererRegistry,
1713
+ UNIVERSAL_CDN,
1714
+ UniversalApp,
1715
+ UniversalAppWithProvider,
1716
+ UniversalProvider,
1717
+ buildAppScript,
1718
+ buildComponentCode,
1719
+ buildDataInjectionCode,
1720
+ buildMinimalRuntime,
1721
+ buildUniversalRuntime,
1722
+ clearRuntimeCache,
1723
+ createContent,
1724
+ createFrontMCPStore,
1725
+ createMarkdownRenderer,
1726
+ createMdxRenderer,
1727
+ createStoreSelector,
1728
+ detectContentType,
1729
+ detectRenderer,
1730
+ getCachedRuntime,
1731
+ getGlobalStore,
1732
+ getRuntimeCacheStats,
1733
+ htmlRenderer,
1734
+ initializeStoreFromWindow,
1735
+ isMdxSupported,
1736
+ isReactComponent,
1737
+ markdownRenderer,
1738
+ mdxRenderer,
1739
+ reactRenderer,
1740
+ renderContent,
1741
+ rendererRegistry,
1742
+ resetGlobalStore,
1743
+ safeHtmlRenderer,
1744
+ setGlobalStore,
1745
+ useComponents,
1746
+ useContent,
1747
+ useFrontMCPContext,
1748
+ useFrontMCPContextSafe,
1749
+ useFrontMCPStore,
1750
+ useLoadingState,
1751
+ useToolInput,
1752
+ useToolName,
1753
+ useToolOutput,
1754
+ withFrontMCP
1755
+ };