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