@frontmcp/ui 0.6.0 → 0.6.2

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 (650) hide show
  1. package/README.md +140 -362
  2. package/bridge/core/bridge-factory.d.ts +1 -0
  3. package/bridge/core/bridge-factory.d.ts.map +1 -1
  4. package/bridge/index.d.ts +1 -1
  5. package/bridge/index.d.ts.map +1 -1
  6. package/bridge/index.js +39 -881
  7. package/bridge/runtime/index.d.ts +2 -1
  8. package/bridge/runtime/index.d.ts.map +1 -1
  9. package/bundler/browser-components.d.ts +42 -0
  10. package/bundler/browser-components.d.ts.map +1 -0
  11. package/bundler/bundler.d.ts +78 -4
  12. package/bundler/bundler.d.ts.map +1 -1
  13. package/bundler/index.d.ts +8 -8
  14. package/bundler/index.d.ts.map +1 -1
  15. package/bundler/index.js +1411 -2997
  16. package/bundler/types.d.ts +188 -7
  17. package/bundler/types.d.ts.map +1 -1
  18. package/components/alert.schema.d.ts +6 -6
  19. package/components/avatar.schema.d.ts +9 -9
  20. package/components/badge.schema.d.ts +9 -9
  21. package/components/button.schema.d.ts +9 -9
  22. package/components/card.schema.d.ts +7 -7
  23. package/components/form.schema.d.ts +24 -24
  24. package/components/index.js +128 -198
  25. package/components/modal.schema.d.ts +8 -8
  26. package/components/table.schema.d.ts +6 -6
  27. package/esm/bridge/{index.js → index.mjs} +40 -877
  28. package/esm/bundler/index.mjs +3136 -0
  29. package/esm/components/{index.js → index.mjs} +136 -196
  30. package/esm/index.mjs +5450 -0
  31. package/esm/layouts/index.mjs +409 -0
  32. package/esm/package.json +15 -32
  33. package/esm/react/{index.js → index.mjs} +71 -260
  34. package/esm/renderers/index.mjs +611 -0
  35. package/esm/universal/index.mjs +1951 -0
  36. package/esm/web-components/{index.js → index.mjs} +232 -287
  37. package/index.d.ts +22 -41
  38. package/index.d.ts.map +1 -1
  39. package/index.js +4286 -19607
  40. package/layouts/base.d.ts +2 -2
  41. package/layouts/base.d.ts.map +1 -1
  42. package/layouts/index.js +46 -539
  43. package/layouts/presets.d.ts.map +1 -1
  44. package/package.json +15 -32
  45. package/react/Alert.d.ts +1 -2
  46. package/react/Alert.d.ts.map +1 -1
  47. package/react/Badge.d.ts +1 -2
  48. package/react/Badge.d.ts.map +1 -1
  49. package/react/Button.d.ts +1 -2
  50. package/react/Button.d.ts.map +1 -1
  51. package/react/Card.d.ts +1 -2
  52. package/react/Card.d.ts.map +1 -1
  53. package/react/hooks/context.d.ts +1 -1
  54. package/react/hooks/context.d.ts.map +1 -1
  55. package/react/index.d.ts +5 -7
  56. package/react/index.d.ts.map +1 -1
  57. package/react/index.js +55 -269
  58. package/react/types.d.ts +1 -2
  59. package/react/types.d.ts.map +1 -1
  60. package/renderers/index.d.ts +15 -25
  61. package/renderers/index.d.ts.map +1 -1
  62. package/renderers/index.js +393 -1619
  63. package/renderers/mdx.renderer.d.ts +13 -34
  64. package/renderers/mdx.renderer.d.ts.map +1 -1
  65. package/{esm/runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  66. package/renderers/react.adapter.d.ts.map +1 -0
  67. package/renderers/react.renderer.d.ts +25 -16
  68. package/renderers/react.renderer.d.ts.map +1 -1
  69. package/renderers/transpiler.d.ts +49 -0
  70. package/renderers/transpiler.d.ts.map +1 -0
  71. package/universal/cached-runtime.d.ts +25 -1
  72. package/universal/cached-runtime.d.ts.map +1 -1
  73. package/universal/index.js +2037 -0
  74. package/universal/runtime-builder.d.ts.map +1 -1
  75. package/universal/types.d.ts.map +1 -1
  76. package/web-components/elements/fmcp-input.d.ts.map +1 -1
  77. package/web-components/elements/fmcp-select.d.ts.map +1 -1
  78. package/web-components/index.d.ts +0 -1
  79. package/web-components/index.d.ts.map +1 -1
  80. package/web-components/index.js +224 -289
  81. package/adapters/index.d.ts +0 -13
  82. package/adapters/index.d.ts.map +0 -1
  83. package/adapters/index.js +0 -462
  84. package/adapters/platform-meta.d.ts +0 -166
  85. package/adapters/platform-meta.d.ts.map +0 -1
  86. package/adapters/response-builder.d.ts +0 -108
  87. package/adapters/response-builder.d.ts.map +0 -1
  88. package/adapters/serving-mode.d.ts +0 -107
  89. package/adapters/serving-mode.d.ts.map +0 -1
  90. package/base-template/bridge.d.ts +0 -90
  91. package/base-template/bridge.d.ts.map +0 -1
  92. package/base-template/default-base-template.d.ts +0 -92
  93. package/base-template/default-base-template.d.ts.map +0 -1
  94. package/base-template/index.d.ts +0 -15
  95. package/base-template/index.d.ts.map +0 -1
  96. package/base-template/index.js +0 -1398
  97. package/base-template/polyfills.d.ts +0 -31
  98. package/base-template/polyfills.d.ts.map +0 -1
  99. package/base-template/theme-styles.d.ts +0 -74
  100. package/base-template/theme-styles.d.ts.map +0 -1
  101. package/build/cdn-resources.d.ts +0 -243
  102. package/build/cdn-resources.d.ts.map +0 -1
  103. package/build/index.d.ts +0 -295
  104. package/build/index.d.ts.map +0 -1
  105. package/build/index.js +0 -7096
  106. package/build/widget-manifest.d.ts +0 -362
  107. package/build/widget-manifest.d.ts.map +0 -1
  108. package/bundler/cache.d.ts +0 -173
  109. package/bundler/cache.d.ts.map +0 -1
  110. package/bundler/file-cache/component-builder.d.ts +0 -167
  111. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  112. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  113. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  114. package/bundler/file-cache/index.d.ts +0 -12
  115. package/bundler/file-cache/index.d.ts.map +0 -1
  116. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  117. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  118. package/bundler/file-cache/storage/index.d.ts +0 -11
  119. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  120. package/bundler/file-cache/storage/interface.d.ts +0 -152
  121. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  122. package/bundler/file-cache/storage/redis.d.ts +0 -139
  123. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  124. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  125. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  126. package/bundler/sandbox/executor.d.ts +0 -14
  127. package/bundler/sandbox/executor.d.ts.map +0 -1
  128. package/bundler/sandbox/policy.d.ts +0 -62
  129. package/bundler/sandbox/policy.d.ts.map +0 -1
  130. package/dependency/cdn-registry.d.ts +0 -98
  131. package/dependency/cdn-registry.d.ts.map +0 -1
  132. package/dependency/import-map.d.ts +0 -186
  133. package/dependency/import-map.d.ts.map +0 -1
  134. package/dependency/import-parser.d.ts +0 -82
  135. package/dependency/import-parser.d.ts.map +0 -1
  136. package/dependency/index.d.ts +0 -17
  137. package/dependency/index.d.ts.map +0 -1
  138. package/dependency/resolver.d.ts +0 -164
  139. package/dependency/resolver.d.ts.map +0 -1
  140. package/dependency/schemas.d.ts +0 -486
  141. package/dependency/schemas.d.ts.map +0 -1
  142. package/dependency/template-loader.d.ts +0 -204
  143. package/dependency/template-loader.d.ts.map +0 -1
  144. package/dependency/template-processor.d.ts +0 -118
  145. package/dependency/template-processor.d.ts.map +0 -1
  146. package/dependency/types.d.ts +0 -739
  147. package/dependency/types.d.ts.map +0 -1
  148. package/esm/adapters/index.d.ts +0 -13
  149. package/esm/adapters/index.d.ts.map +0 -1
  150. package/esm/adapters/index.js +0 -427
  151. package/esm/adapters/platform-meta.d.ts +0 -166
  152. package/esm/adapters/platform-meta.d.ts.map +0 -1
  153. package/esm/adapters/response-builder.d.ts +0 -108
  154. package/esm/adapters/response-builder.d.ts.map +0 -1
  155. package/esm/adapters/serving-mode.d.ts +0 -107
  156. package/esm/adapters/serving-mode.d.ts.map +0 -1
  157. package/esm/base-template/bridge.d.ts +0 -90
  158. package/esm/base-template/bridge.d.ts.map +0 -1
  159. package/esm/base-template/default-base-template.d.ts +0 -92
  160. package/esm/base-template/default-base-template.d.ts.map +0 -1
  161. package/esm/base-template/index.d.ts +0 -15
  162. package/esm/base-template/index.d.ts.map +0 -1
  163. package/esm/base-template/index.js +0 -1364
  164. package/esm/base-template/polyfills.d.ts +0 -31
  165. package/esm/base-template/polyfills.d.ts.map +0 -1
  166. package/esm/base-template/theme-styles.d.ts +0 -74
  167. package/esm/base-template/theme-styles.d.ts.map +0 -1
  168. package/esm/bridge/adapters/base-adapter.d.ts +0 -104
  169. package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
  170. package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
  171. package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
  172. package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
  173. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
  174. package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
  175. package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
  176. package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
  177. package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
  178. package/esm/bridge/adapters/index.d.ts +0 -26
  179. package/esm/bridge/adapters/index.d.ts.map +0 -1
  180. package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
  181. package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
  182. package/esm/bridge/core/adapter-registry.d.ts +0 -122
  183. package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
  184. package/esm/bridge/core/bridge-factory.d.ts +0 -199
  185. package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
  186. package/esm/bridge/core/index.d.ts +0 -10
  187. package/esm/bridge/core/index.d.ts.map +0 -1
  188. package/esm/bridge/index.d.ts +0 -62
  189. package/esm/bridge/index.d.ts.map +0 -1
  190. package/esm/bridge/runtime/iife-generator.d.ts +0 -62
  191. package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
  192. package/esm/bridge/runtime/index.d.ts +0 -9
  193. package/esm/bridge/runtime/index.d.ts.map +0 -1
  194. package/esm/bridge/types.d.ts +0 -386
  195. package/esm/bridge/types.d.ts.map +0 -1
  196. package/esm/build/cdn-resources.d.ts +0 -243
  197. package/esm/build/cdn-resources.d.ts.map +0 -1
  198. package/esm/build/index.d.ts +0 -295
  199. package/esm/build/index.d.ts.map +0 -1
  200. package/esm/build/index.js +0 -7021
  201. package/esm/build/widget-manifest.d.ts +0 -362
  202. package/esm/build/widget-manifest.d.ts.map +0 -1
  203. package/esm/bundler/bundler.d.ts +0 -208
  204. package/esm/bundler/bundler.d.ts.map +0 -1
  205. package/esm/bundler/cache.d.ts +0 -173
  206. package/esm/bundler/cache.d.ts.map +0 -1
  207. package/esm/bundler/file-cache/component-builder.d.ts +0 -167
  208. package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
  209. package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
  210. package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  211. package/esm/bundler/file-cache/index.d.ts +0 -12
  212. package/esm/bundler/file-cache/index.d.ts.map +0 -1
  213. package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
  214. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  215. package/esm/bundler/file-cache/storage/index.d.ts +0 -11
  216. package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
  217. package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
  218. package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
  219. package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
  220. package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
  221. package/esm/bundler/index.d.ts +0 -43
  222. package/esm/bundler/index.d.ts.map +0 -1
  223. package/esm/bundler/index.js +0 -4687
  224. package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
  225. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  226. package/esm/bundler/sandbox/executor.d.ts +0 -14
  227. package/esm/bundler/sandbox/executor.d.ts.map +0 -1
  228. package/esm/bundler/sandbox/policy.d.ts +0 -62
  229. package/esm/bundler/sandbox/policy.d.ts.map +0 -1
  230. package/esm/bundler/types.d.ts +0 -702
  231. package/esm/bundler/types.d.ts.map +0 -1
  232. package/esm/components/alert.d.ts +0 -66
  233. package/esm/components/alert.d.ts.map +0 -1
  234. package/esm/components/alert.schema.d.ts +0 -98
  235. package/esm/components/alert.schema.d.ts.map +0 -1
  236. package/esm/components/avatar.d.ts +0 -77
  237. package/esm/components/avatar.d.ts.map +0 -1
  238. package/esm/components/avatar.schema.d.ts +0 -170
  239. package/esm/components/avatar.schema.d.ts.map +0 -1
  240. package/esm/components/badge.d.ts +0 -64
  241. package/esm/components/badge.d.ts.map +0 -1
  242. package/esm/components/badge.schema.d.ts +0 -91
  243. package/esm/components/badge.schema.d.ts.map +0 -1
  244. package/esm/components/button.d.ts +0 -100
  245. package/esm/components/button.d.ts.map +0 -1
  246. package/esm/components/button.schema.d.ts +0 -120
  247. package/esm/components/button.schema.d.ts.map +0 -1
  248. package/esm/components/card.d.ts +0 -53
  249. package/esm/components/card.d.ts.map +0 -1
  250. package/esm/components/card.schema.d.ts +0 -93
  251. package/esm/components/card.schema.d.ts.map +0 -1
  252. package/esm/components/form.d.ts +0 -212
  253. package/esm/components/form.d.ts.map +0 -1
  254. package/esm/components/form.schema.d.ts +0 -365
  255. package/esm/components/form.schema.d.ts.map +0 -1
  256. package/esm/components/index.d.ts +0 -29
  257. package/esm/components/index.d.ts.map +0 -1
  258. package/esm/components/list.d.ts +0 -121
  259. package/esm/components/list.d.ts.map +0 -1
  260. package/esm/components/list.schema.d.ts +0 -129
  261. package/esm/components/list.schema.d.ts.map +0 -1
  262. package/esm/components/modal.d.ts +0 -100
  263. package/esm/components/modal.d.ts.map +0 -1
  264. package/esm/components/modal.schema.d.ts +0 -151
  265. package/esm/components/modal.schema.d.ts.map +0 -1
  266. package/esm/components/table.d.ts +0 -91
  267. package/esm/components/table.d.ts.map +0 -1
  268. package/esm/components/table.schema.d.ts +0 -123
  269. package/esm/components/table.schema.d.ts.map +0 -1
  270. package/esm/dependency/cdn-registry.d.ts +0 -98
  271. package/esm/dependency/cdn-registry.d.ts.map +0 -1
  272. package/esm/dependency/import-map.d.ts +0 -186
  273. package/esm/dependency/import-map.d.ts.map +0 -1
  274. package/esm/dependency/import-parser.d.ts +0 -82
  275. package/esm/dependency/import-parser.d.ts.map +0 -1
  276. package/esm/dependency/index.d.ts +0 -17
  277. package/esm/dependency/index.d.ts.map +0 -1
  278. package/esm/dependency/resolver.d.ts +0 -164
  279. package/esm/dependency/resolver.d.ts.map +0 -1
  280. package/esm/dependency/schemas.d.ts +0 -486
  281. package/esm/dependency/schemas.d.ts.map +0 -1
  282. package/esm/dependency/template-loader.d.ts +0 -204
  283. package/esm/dependency/template-loader.d.ts.map +0 -1
  284. package/esm/dependency/template-processor.d.ts +0 -118
  285. package/esm/dependency/template-processor.d.ts.map +0 -1
  286. package/esm/dependency/types.d.ts +0 -739
  287. package/esm/dependency/types.d.ts.map +0 -1
  288. package/esm/handlebars/expression-extractor.d.ts +0 -147
  289. package/esm/handlebars/expression-extractor.d.ts.map +0 -1
  290. package/esm/handlebars/helpers.d.ts +0 -339
  291. package/esm/handlebars/helpers.d.ts.map +0 -1
  292. package/esm/handlebars/index.d.ts +0 -195
  293. package/esm/handlebars/index.d.ts.map +0 -1
  294. package/esm/handlebars/index.js +0 -587
  295. package/esm/index.d.ts +0 -56
  296. package/esm/index.d.ts.map +0 -1
  297. package/esm/index.js +0 -20511
  298. package/esm/layouts/base.d.ts +0 -86
  299. package/esm/layouts/base.d.ts.map +0 -1
  300. package/esm/layouts/index.d.ts +0 -8
  301. package/esm/layouts/index.d.ts.map +0 -1
  302. package/esm/layouts/index.js +0 -892
  303. package/esm/layouts/presets.d.ts +0 -134
  304. package/esm/layouts/presets.d.ts.map +0 -1
  305. package/esm/pages/consent.d.ts +0 -117
  306. package/esm/pages/consent.d.ts.map +0 -1
  307. package/esm/pages/error.d.ts +0 -101
  308. package/esm/pages/error.d.ts.map +0 -1
  309. package/esm/pages/index.d.ts +0 -9
  310. package/esm/pages/index.d.ts.map +0 -1
  311. package/esm/pages/index.js +0 -1563
  312. package/esm/react/Alert.d.ts +0 -102
  313. package/esm/react/Alert.d.ts.map +0 -1
  314. package/esm/react/Badge.d.ts +0 -101
  315. package/esm/react/Badge.d.ts.map +0 -1
  316. package/esm/react/Button.d.ts +0 -109
  317. package/esm/react/Button.d.ts.map +0 -1
  318. package/esm/react/Card.d.ts +0 -104
  319. package/esm/react/Card.d.ts.map +0 -1
  320. package/esm/react/hooks/context.d.ts +0 -179
  321. package/esm/react/hooks/context.d.ts.map +0 -1
  322. package/esm/react/hooks/index.d.ts +0 -42
  323. package/esm/react/hooks/index.d.ts.map +0 -1
  324. package/esm/react/hooks/tools.d.ts +0 -284
  325. package/esm/react/hooks/tools.d.ts.map +0 -1
  326. package/esm/react/index.d.ts +0 -81
  327. package/esm/react/index.d.ts.map +0 -1
  328. package/esm/react/types.d.ts +0 -106
  329. package/esm/react/types.d.ts.map +0 -1
  330. package/esm/react/utils.d.ts +0 -43
  331. package/esm/react/utils.d.ts.map +0 -1
  332. package/esm/registry/index.d.ts +0 -46
  333. package/esm/registry/index.d.ts.map +0 -1
  334. package/esm/registry/index.js +0 -6422
  335. package/esm/registry/render-template.d.ts +0 -91
  336. package/esm/registry/render-template.d.ts.map +0 -1
  337. package/esm/registry/tool-ui.registry.d.ts +0 -294
  338. package/esm/registry/tool-ui.registry.d.ts.map +0 -1
  339. package/esm/registry/uri-utils.d.ts +0 -56
  340. package/esm/registry/uri-utils.d.ts.map +0 -1
  341. package/esm/render/index.d.ts +0 -8
  342. package/esm/render/index.d.ts.map +0 -1
  343. package/esm/render/prerender.d.ts +0 -57
  344. package/esm/render/prerender.d.ts.map +0 -1
  345. package/esm/renderers/cache.d.ts +0 -145
  346. package/esm/renderers/cache.d.ts.map +0 -1
  347. package/esm/renderers/html.renderer.d.ts +0 -123
  348. package/esm/renderers/html.renderer.d.ts.map +0 -1
  349. package/esm/renderers/index.d.ts +0 -36
  350. package/esm/renderers/index.d.ts.map +0 -1
  351. package/esm/renderers/index.js +0 -1827
  352. package/esm/renderers/mdx.renderer.d.ts +0 -120
  353. package/esm/renderers/mdx.renderer.d.ts.map +0 -1
  354. package/esm/renderers/react.renderer.d.ts +0 -96
  355. package/esm/renderers/react.renderer.d.ts.map +0 -1
  356. package/esm/renderers/registry.d.ts +0 -134
  357. package/esm/renderers/registry.d.ts.map +0 -1
  358. package/esm/renderers/types.d.ts +0 -342
  359. package/esm/renderers/types.d.ts.map +0 -1
  360. package/esm/renderers/utils/detect.d.ts +0 -107
  361. package/esm/renderers/utils/detect.d.ts.map +0 -1
  362. package/esm/renderers/utils/hash.d.ts +0 -40
  363. package/esm/renderers/utils/hash.d.ts.map +0 -1
  364. package/esm/renderers/utils/index.d.ts +0 -9
  365. package/esm/renderers/utils/index.d.ts.map +0 -1
  366. package/esm/renderers/utils/transpiler.d.ts +0 -89
  367. package/esm/renderers/utils/transpiler.d.ts.map +0 -1
  368. package/esm/runtime/adapters/html.adapter.d.ts +0 -59
  369. package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
  370. package/esm/runtime/adapters/index.d.ts +0 -26
  371. package/esm/runtime/adapters/index.d.ts.map +0 -1
  372. package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
  373. package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  374. package/esm/runtime/adapters/react.adapter.d.ts.map +0 -1
  375. package/esm/runtime/adapters/types.d.ts +0 -95
  376. package/esm/runtime/adapters/types.d.ts.map +0 -1
  377. package/esm/runtime/csp.d.ts +0 -48
  378. package/esm/runtime/csp.d.ts.map +0 -1
  379. package/esm/runtime/index.d.ts +0 -17
  380. package/esm/runtime/index.d.ts.map +0 -1
  381. package/esm/runtime/index.js +0 -5186
  382. package/esm/runtime/mcp-bridge.d.ts +0 -101
  383. package/esm/runtime/mcp-bridge.d.ts.map +0 -1
  384. package/esm/runtime/renderer-runtime.d.ts +0 -133
  385. package/esm/runtime/renderer-runtime.d.ts.map +0 -1
  386. package/esm/runtime/sanitizer.d.ts +0 -172
  387. package/esm/runtime/sanitizer.d.ts.map +0 -1
  388. package/esm/runtime/types.d.ts +0 -415
  389. package/esm/runtime/types.d.ts.map +0 -1
  390. package/esm/runtime/wrapper.d.ts +0 -421
  391. package/esm/runtime/wrapper.d.ts.map +0 -1
  392. package/esm/styles/index.d.ts +0 -8
  393. package/esm/styles/index.d.ts.map +0 -1
  394. package/esm/styles/index.js +0 -171
  395. package/esm/styles/variants.d.ts +0 -51
  396. package/esm/styles/variants.d.ts.map +0 -1
  397. package/esm/theme/cdn.d.ts +0 -195
  398. package/esm/theme/cdn.d.ts.map +0 -1
  399. package/esm/theme/index.d.ts +0 -18
  400. package/esm/theme/index.d.ts.map +0 -1
  401. package/esm/theme/index.js +0 -700
  402. package/esm/theme/platforms.d.ts +0 -107
  403. package/esm/theme/platforms.d.ts.map +0 -1
  404. package/esm/theme/presets/github-openai.d.ts +0 -50
  405. package/esm/theme/presets/github-openai.d.ts.map +0 -1
  406. package/esm/theme/presets/index.d.ts +0 -11
  407. package/esm/theme/presets/index.d.ts.map +0 -1
  408. package/esm/theme/theme.d.ts +0 -396
  409. package/esm/theme/theme.d.ts.map +0 -1
  410. package/esm/tool-template/builder.d.ts +0 -213
  411. package/esm/tool-template/builder.d.ts.map +0 -1
  412. package/esm/tool-template/index.d.ts +0 -16
  413. package/esm/tool-template/index.d.ts.map +0 -1
  414. package/esm/tool-template/index.js +0 -3515
  415. package/esm/types/index.d.ts +0 -14
  416. package/esm/types/index.d.ts.map +0 -1
  417. package/esm/types/index.js +0 -75
  418. package/esm/types/ui-config.d.ts +0 -639
  419. package/esm/types/ui-config.d.ts.map +0 -1
  420. package/esm/types/ui-runtime.d.ts +0 -1007
  421. package/esm/types/ui-runtime.d.ts.map +0 -1
  422. package/esm/typings/cache/cache-adapter.d.ts +0 -125
  423. package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
  424. package/esm/typings/cache/index.d.ts +0 -10
  425. package/esm/typings/cache/index.d.ts.map +0 -1
  426. package/esm/typings/cache/memory-cache.d.ts +0 -92
  427. package/esm/typings/cache/memory-cache.d.ts.map +0 -1
  428. package/esm/typings/dts-parser.d.ts +0 -90
  429. package/esm/typings/dts-parser.d.ts.map +0 -1
  430. package/esm/typings/index.d.ts +0 -48
  431. package/esm/typings/index.d.ts.map +0 -1
  432. package/esm/typings/schemas.d.ts +0 -232
  433. package/esm/typings/schemas.d.ts.map +0 -1
  434. package/esm/typings/type-fetcher.d.ts +0 -89
  435. package/esm/typings/type-fetcher.d.ts.map +0 -1
  436. package/esm/typings/types.d.ts +0 -320
  437. package/esm/typings/types.d.ts.map +0 -1
  438. package/esm/universal/UniversalApp.d.ts +0 -108
  439. package/esm/universal/UniversalApp.d.ts.map +0 -1
  440. package/esm/universal/cached-runtime.d.ts +0 -115
  441. package/esm/universal/cached-runtime.d.ts.map +0 -1
  442. package/esm/universal/context.d.ts +0 -122
  443. package/esm/universal/context.d.ts.map +0 -1
  444. package/esm/universal/index.d.ts +0 -57
  445. package/esm/universal/index.d.ts.map +0 -1
  446. package/esm/universal/renderers/html.renderer.d.ts +0 -37
  447. package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
  448. package/esm/universal/renderers/index.d.ts +0 -112
  449. package/esm/universal/renderers/index.d.ts.map +0 -1
  450. package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
  451. package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
  452. package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
  453. package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
  454. package/esm/universal/renderers/react.renderer.d.ts +0 -46
  455. package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
  456. package/esm/universal/runtime-builder.d.ts +0 -33
  457. package/esm/universal/runtime-builder.d.ts.map +0 -1
  458. package/esm/universal/store.d.ts +0 -135
  459. package/esm/universal/store.d.ts.map +0 -1
  460. package/esm/universal/types.d.ts +0 -199
  461. package/esm/universal/types.d.ts.map +0 -1
  462. package/esm/utils/escape-html.d.ts +0 -58
  463. package/esm/utils/escape-html.d.ts.map +0 -1
  464. package/esm/utils/index.d.ts +0 -10
  465. package/esm/utils/index.d.ts.map +0 -1
  466. package/esm/utils/index.js +0 -40
  467. package/esm/utils/safe-stringify.d.ts +0 -30
  468. package/esm/utils/safe-stringify.d.ts.map +0 -1
  469. package/esm/validation/error-box.d.ts +0 -56
  470. package/esm/validation/error-box.d.ts.map +0 -1
  471. package/esm/validation/index.d.ts +0 -13
  472. package/esm/validation/index.d.ts.map +0 -1
  473. package/esm/validation/index.js +0 -562
  474. package/esm/validation/schema-paths.d.ts +0 -118
  475. package/esm/validation/schema-paths.d.ts.map +0 -1
  476. package/esm/validation/template-validator.d.ts +0 -143
  477. package/esm/validation/template-validator.d.ts.map +0 -1
  478. package/esm/validation/wrapper.d.ts +0 -97
  479. package/esm/validation/wrapper.d.ts.map +0 -1
  480. package/esm/web-components/core/attribute-parser.d.ts +0 -82
  481. package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
  482. package/esm/web-components/core/base-element.d.ts +0 -197
  483. package/esm/web-components/core/base-element.d.ts.map +0 -1
  484. package/esm/web-components/core/index.d.ts +0 -9
  485. package/esm/web-components/core/index.d.ts.map +0 -1
  486. package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
  487. package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
  488. package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
  489. package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
  490. package/esm/web-components/elements/fmcp-button.d.ts +0 -117
  491. package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
  492. package/esm/web-components/elements/fmcp-card.d.ts +0 -53
  493. package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
  494. package/esm/web-components/elements/fmcp-input.d.ts +0 -96
  495. package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
  496. package/esm/web-components/elements/fmcp-select.d.ts +0 -100
  497. package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
  498. package/esm/web-components/elements/index.d.ts +0 -13
  499. package/esm/web-components/elements/index.d.ts.map +0 -1
  500. package/esm/web-components/index.d.ts +0 -50
  501. package/esm/web-components/index.d.ts.map +0 -1
  502. package/esm/web-components/register.d.ts +0 -57
  503. package/esm/web-components/register.d.ts.map +0 -1
  504. package/esm/web-components/types.d.ts +0 -122
  505. package/esm/web-components/types.d.ts.map +0 -1
  506. package/esm/widgets/index.d.ts +0 -8
  507. package/esm/widgets/index.d.ts.map +0 -1
  508. package/esm/widgets/index.js +0 -941
  509. package/esm/widgets/progress.d.ts +0 -133
  510. package/esm/widgets/progress.d.ts.map +0 -1
  511. package/esm/widgets/resource.d.ts +0 -163
  512. package/esm/widgets/resource.d.ts.map +0 -1
  513. package/handlebars/expression-extractor.d.ts +0 -147
  514. package/handlebars/expression-extractor.d.ts.map +0 -1
  515. package/handlebars/helpers.d.ts +0 -339
  516. package/handlebars/helpers.d.ts.map +0 -1
  517. package/handlebars/index.d.ts +0 -195
  518. package/handlebars/index.d.ts.map +0 -1
  519. package/handlebars/index.js +0 -666
  520. package/pages/consent.d.ts +0 -117
  521. package/pages/consent.d.ts.map +0 -1
  522. package/pages/error.d.ts +0 -101
  523. package/pages/error.d.ts.map +0 -1
  524. package/pages/index.d.ts +0 -9
  525. package/pages/index.d.ts.map +0 -1
  526. package/pages/index.js +0 -1602
  527. package/react/utils.d.ts +0 -43
  528. package/react/utils.d.ts.map +0 -1
  529. package/registry/index.d.ts +0 -46
  530. package/registry/index.d.ts.map +0 -1
  531. package/registry/index.js +0 -6465
  532. package/registry/render-template.d.ts +0 -91
  533. package/registry/render-template.d.ts.map +0 -1
  534. package/registry/tool-ui.registry.d.ts +0 -294
  535. package/registry/tool-ui.registry.d.ts.map +0 -1
  536. package/registry/uri-utils.d.ts +0 -56
  537. package/registry/uri-utils.d.ts.map +0 -1
  538. package/renderers/cache.d.ts +0 -145
  539. package/renderers/cache.d.ts.map +0 -1
  540. package/renderers/html.renderer.d.ts +0 -123
  541. package/renderers/html.renderer.d.ts.map +0 -1
  542. package/renderers/registry.d.ts +0 -134
  543. package/renderers/registry.d.ts.map +0 -1
  544. package/renderers/types.d.ts +0 -342
  545. package/renderers/types.d.ts.map +0 -1
  546. package/renderers/utils/detect.d.ts +0 -107
  547. package/renderers/utils/detect.d.ts.map +0 -1
  548. package/renderers/utils/hash.d.ts +0 -40
  549. package/renderers/utils/hash.d.ts.map +0 -1
  550. package/renderers/utils/index.d.ts +0 -9
  551. package/renderers/utils/index.d.ts.map +0 -1
  552. package/renderers/utils/transpiler.d.ts +0 -89
  553. package/renderers/utils/transpiler.d.ts.map +0 -1
  554. package/runtime/adapters/html.adapter.d.ts +0 -59
  555. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  556. package/runtime/adapters/index.d.ts +0 -26
  557. package/runtime/adapters/index.d.ts.map +0 -1
  558. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  559. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  560. package/runtime/adapters/react.adapter.d.ts +0 -70
  561. package/runtime/adapters/react.adapter.d.ts.map +0 -1
  562. package/runtime/adapters/types.d.ts +0 -95
  563. package/runtime/adapters/types.d.ts.map +0 -1
  564. package/runtime/csp.d.ts +0 -48
  565. package/runtime/csp.d.ts.map +0 -1
  566. package/runtime/index.d.ts +0 -17
  567. package/runtime/index.d.ts.map +0 -1
  568. package/runtime/index.js +0 -5264
  569. package/runtime/mcp-bridge.d.ts +0 -101
  570. package/runtime/mcp-bridge.d.ts.map +0 -1
  571. package/runtime/renderer-runtime.d.ts +0 -133
  572. package/runtime/renderer-runtime.d.ts.map +0 -1
  573. package/runtime/sanitizer.d.ts +0 -172
  574. package/runtime/sanitizer.d.ts.map +0 -1
  575. package/runtime/types.d.ts +0 -415
  576. package/runtime/types.d.ts.map +0 -1
  577. package/runtime/wrapper.d.ts +0 -421
  578. package/runtime/wrapper.d.ts.map +0 -1
  579. package/styles/index.d.ts +0 -8
  580. package/styles/index.d.ts.map +0 -1
  581. package/styles/index.js +0 -222
  582. package/styles/variants.d.ts +0 -51
  583. package/styles/variants.d.ts.map +0 -1
  584. package/theme/cdn.d.ts +0 -195
  585. package/theme/cdn.d.ts.map +0 -1
  586. package/theme/index.d.ts +0 -18
  587. package/theme/index.d.ts.map +0 -1
  588. package/theme/index.js +0 -757
  589. package/theme/platforms.d.ts +0 -107
  590. package/theme/platforms.d.ts.map +0 -1
  591. package/theme/presets/github-openai.d.ts +0 -50
  592. package/theme/presets/github-openai.d.ts.map +0 -1
  593. package/theme/presets/index.d.ts +0 -11
  594. package/theme/presets/index.d.ts.map +0 -1
  595. package/theme/theme.d.ts +0 -396
  596. package/theme/theme.d.ts.map +0 -1
  597. package/tool-template/builder.d.ts +0 -213
  598. package/tool-template/builder.d.ts.map +0 -1
  599. package/tool-template/index.d.ts +0 -16
  600. package/tool-template/index.d.ts.map +0 -1
  601. package/tool-template/index.js +0 -3559
  602. package/types/index.d.ts +0 -14
  603. package/types/index.d.ts.map +0 -1
  604. package/types/index.js +0 -108
  605. package/types/ui-config.d.ts +0 -639
  606. package/types/ui-config.d.ts.map +0 -1
  607. package/types/ui-runtime.d.ts +0 -1007
  608. package/types/ui-runtime.d.ts.map +0 -1
  609. package/typings/cache/cache-adapter.d.ts +0 -125
  610. package/typings/cache/cache-adapter.d.ts.map +0 -1
  611. package/typings/cache/index.d.ts +0 -10
  612. package/typings/cache/index.d.ts.map +0 -1
  613. package/typings/cache/memory-cache.d.ts +0 -92
  614. package/typings/cache/memory-cache.d.ts.map +0 -1
  615. package/typings/dts-parser.d.ts +0 -90
  616. package/typings/dts-parser.d.ts.map +0 -1
  617. package/typings/index.d.ts +0 -48
  618. package/typings/index.d.ts.map +0 -1
  619. package/typings/schemas.d.ts +0 -232
  620. package/typings/schemas.d.ts.map +0 -1
  621. package/typings/type-fetcher.d.ts +0 -89
  622. package/typings/type-fetcher.d.ts.map +0 -1
  623. package/typings/types.d.ts +0 -320
  624. package/typings/types.d.ts.map +0 -1
  625. package/utils/escape-html.d.ts +0 -58
  626. package/utils/escape-html.d.ts.map +0 -1
  627. package/utils/index.d.ts +0 -10
  628. package/utils/index.d.ts.map +0 -1
  629. package/utils/index.js +0 -70
  630. package/utils/safe-stringify.d.ts +0 -30
  631. package/utils/safe-stringify.d.ts.map +0 -1
  632. package/validation/error-box.d.ts +0 -56
  633. package/validation/error-box.d.ts.map +0 -1
  634. package/validation/index.d.ts +0 -13
  635. package/validation/index.d.ts.map +0 -1
  636. package/validation/index.js +0 -603
  637. package/validation/schema-paths.d.ts +0 -118
  638. package/validation/schema-paths.d.ts.map +0 -1
  639. package/validation/template-validator.d.ts +0 -143
  640. package/validation/template-validator.d.ts.map +0 -1
  641. package/validation/wrapper.d.ts +0 -97
  642. package/validation/wrapper.d.ts.map +0 -1
  643. package/widgets/index.d.ts +0 -8
  644. package/widgets/index.d.ts.map +0 -1
  645. package/widgets/index.js +0 -978
  646. package/widgets/progress.d.ts +0 -133
  647. package/widgets/progress.d.ts.map +0 -1
  648. package/widgets/resource.d.ts +0 -163
  649. package/widgets/resource.d.ts.map +0 -1
  650. /package/esm/render/{index.js → index.mjs} +0 -0
@@ -0,0 +1,2037 @@
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(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").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(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").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 import_runtime = require("@frontmcp/uipack/runtime");
1181
+ var import_build = require("@frontmcp/uipack/build");
1182
+ var RUNTIME_PLACEHOLDERS = {
1183
+ /** Placeholder for transpiled component code */
1184
+ COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/",
1185
+ /** Placeholder for data injection */
1186
+ DATA_INJECTION: "/*__FRONTMCP_DATA_INJECTION__*/",
1187
+ /** Placeholder for custom components */
1188
+ CUSTOM_COMPONENTS: "/*__FRONTMCP_CUSTOM_COMPONENTS__*/"
1189
+ };
1190
+ var runtimeCache = /* @__PURE__ */ new Map();
1191
+ var DEFAULT_CACHE_CONFIG = {
1192
+ maxEntries: 10,
1193
+ ttl: 0
1194
+ // Forever by default
1195
+ };
1196
+ function generateCacheKey(options) {
1197
+ const securityKey = options.contentSecurity ? [
1198
+ options.contentSecurity.allowUnsafeLinks ? "unsafeLinks" : "",
1199
+ options.contentSecurity.allowInlineScripts ? "unsafeScripts" : "",
1200
+ options.contentSecurity.bypassSanitization ? "bypass" : ""
1201
+ ].filter(Boolean).join("+") || "secure" : "secure";
1202
+ return [
1203
+ options.cdnType,
1204
+ options.includeMarkdown ? "md" : "",
1205
+ options.includeMdx ? "mdx" : "",
1206
+ options.minify ? "min" : "",
1207
+ options.includeBridge ? "bridge" : "",
1208
+ securityKey
1209
+ ].filter(Boolean).join(":");
1210
+ }
1211
+ function buildStoreRuntime2() {
1212
+ return `
1213
+ // FrontMCP Store (Vendor)
1214
+ (function() {
1215
+ var state = {
1216
+ toolName: null,
1217
+ input: null,
1218
+ output: null,
1219
+ content: null,
1220
+ structuredContent: null,
1221
+ loading: false,
1222
+ error: null
1223
+ };
1224
+
1225
+ var listeners = new Set();
1226
+
1227
+ window.__frontmcp = {
1228
+ getState: function() { return state; },
1229
+ setState: function(partial) {
1230
+ state = Object.assign({}, state, partial);
1231
+ listeners.forEach(function(fn) { fn(); });
1232
+ },
1233
+ subscribe: function(fn) {
1234
+ listeners.add(fn);
1235
+ return function() { listeners.delete(fn); };
1236
+ },
1237
+ reset: function() {
1238
+ state = {
1239
+ toolName: null,
1240
+ input: null,
1241
+ output: null,
1242
+ content: null,
1243
+ structuredContent: null,
1244
+ loading: false,
1245
+ error: null
1246
+ };
1247
+ },
1248
+ context: state,
1249
+ setContext: function(ctx) {
1250
+ this.setState(ctx);
1251
+ },
1252
+ // Dynamic mode: update output and re-render
1253
+ updateOutput: function(output) {
1254
+ this.setState({ output: output, loading: false });
1255
+ // Also update the global window variable for compatibility
1256
+ window.__mcpToolOutput = output;
1257
+ },
1258
+ // Dynamic mode: update input and re-render
1259
+ updateInput: function(input) {
1260
+ this.setState({ input: input });
1261
+ window.__mcpToolInput = input;
1262
+ }
1263
+ };
1264
+
1265
+ // React hooks
1266
+ window.useFrontMCPStore = function() {
1267
+ var store = window.__frontmcp;
1268
+ return React.useSyncExternalStore(
1269
+ store.subscribe,
1270
+ store.getState,
1271
+ store.getState
1272
+ );
1273
+ };
1274
+
1275
+ window.useToolOutput = function() {
1276
+ return window.useFrontMCPStore().output;
1277
+ };
1278
+
1279
+ window.useToolInput = function() {
1280
+ return window.useFrontMCPStore().input;
1281
+ };
1282
+
1283
+ window.useContent = function() {
1284
+ return window.useFrontMCPStore().content;
1285
+ };
1286
+
1287
+ // Connect to MCP Bridge for platform data detection
1288
+ function initFromBridge() {
1289
+ // Check for data from mcpBridge (handles OpenAI, ext-apps, etc.)
1290
+ if (window.mcpBridge && window.mcpBridge.toolOutput != null) {
1291
+ window.__frontmcp.setState({
1292
+ output: window.mcpBridge.toolOutput,
1293
+ loading: false
1294
+ });
1295
+ }
1296
+
1297
+ // Subscribe to bridge updates via onToolResult
1298
+ if (window.mcpBridge && window.mcpBridge.onToolResult) {
1299
+ window.mcpBridge.onToolResult(function(result) {
1300
+ window.__frontmcp.updateOutput(result);
1301
+ });
1302
+ }
1303
+ }
1304
+
1305
+ // Initialize from bridge when ready
1306
+ if (window.mcpBridge) {
1307
+ initFromBridge();
1308
+ } else {
1309
+ // Wait for bridge to be ready
1310
+ window.addEventListener('mcp:bridge-ready', initFromBridge);
1311
+ }
1312
+ })();
1313
+ `;
1314
+ }
1315
+ function buildRequireShim() {
1316
+ return `
1317
+ // Module Require Shim (Vendor)
1318
+ (function() {
1319
+ window.__moduleCache = {};
1320
+ window.require = function(moduleName) {
1321
+ if (window.__moduleCache[moduleName]) {
1322
+ return window.__moduleCache[moduleName];
1323
+ }
1324
+
1325
+ var moduleMap = {
1326
+ 'react': function() { return window.React; },
1327
+ 'react-dom': function() { return window.ReactDOM; },
1328
+ 'react-dom/client': function() { return window.ReactDOM; },
1329
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
1330
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
1331
+ '@frontmcp/ui': function() { return window.frontmcp_ui_namespaceObject; },
1332
+ '@frontmcp/ui/react': function() { return window.frontmcp_ui_namespaceObject; }
1333
+ };
1334
+
1335
+ var resolver = moduleMap[moduleName];
1336
+ if (resolver) {
1337
+ var mod = resolver();
1338
+ window.__moduleCache[moduleName] = mod;
1339
+ return mod;
1340
+ }
1341
+
1342
+ console.warn('[FrontMCP] Unknown module:', moduleName);
1343
+ return {};
1344
+ };
1345
+ })();
1346
+ `;
1347
+ }
1348
+ function buildInlineMarkdownParser2(options) {
1349
+ const allowUnsafeLinks = options?.contentSecurity?.bypassSanitization || options?.contentSecurity?.allowUnsafeLinks;
1350
+ return `
1351
+ // Inline Markdown Parser (Vendor)
1352
+ (function() {
1353
+ // XSS protection settings (configured at build time)
1354
+ // Set to true if contentSecurity.allowUnsafeLinks or bypassSanitization is enabled
1355
+ var __allowUnsafeLinks = ${allowUnsafeLinks ? "true" : "false"};
1356
+
1357
+ // URL scheme validation to prevent XSS via javascript: URLs
1358
+ function isSafeUrl(url) {
1359
+ // If unsafe links are explicitly allowed, skip validation
1360
+ if (__allowUnsafeLinks) return true;
1361
+ if (!url) return false;
1362
+ var lower = url.toLowerCase().trim();
1363
+ return lower.startsWith('http://') ||
1364
+ lower.startsWith('https://') ||
1365
+ lower.startsWith('/') ||
1366
+ lower.startsWith('#') ||
1367
+ lower.startsWith('mailto:');
1368
+ }
1369
+
1370
+ function parseMarkdown(md) {
1371
+ var html = md;
1372
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1373
+ html = html.replace(/^######\\s+(.*)$/gm, '<h6>$1</h6>');
1374
+ html = html.replace(/^#####\\s+(.*)$/gm, '<h5>$1</h5>');
1375
+ html = html.replace(/^####\\s+(.*)$/gm, '<h4>$1</h4>');
1376
+ html = html.replace(/^###\\s+(.*)$/gm, '<h3>$1</h3>');
1377
+ html = html.replace(/^##\\s+(.*)$/gm, '<h2>$1</h2>');
1378
+ html = html.replace(/^#\\s+(.*)$/gm, '<h1>$1</h1>');
1379
+ html = html.replace(/\\*\\*\\*(.+?)\\*\\*\\*/g, '<strong><em>$1</em></strong>');
1380
+ html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');
1381
+ html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');
1382
+ html = html.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
1383
+ // Links - validate URL scheme to prevent XSS (unless bypassed)
1384
+ html = html.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, function(match, text, url) {
1385
+ return isSafeUrl(url) ? '<a href="' + url + '">' + text + '</a>' : text;
1386
+ });
1387
+ html = html.replace(/^[-*]\\s+(.*)$/gm, '<li>$1</li>');
1388
+ html = html.replace(/\\n\\n+/g, '</p><p>');
1389
+ html = '<p>' + html + '</p>';
1390
+ return html;
1391
+ }
1392
+
1393
+ window.__frontmcp.parseMarkdown = parseMarkdown;
1394
+
1395
+ window.ReactMarkdown = function(props) {
1396
+ var html = parseMarkdown(props.children || '');
1397
+ return React.createElement('div', {
1398
+ className: 'frontmcp-markdown prose',
1399
+ dangerouslySetInnerHTML: { __html: html }
1400
+ });
1401
+ };
1402
+ })();
1403
+ `;
1404
+ }
1405
+ function buildRenderersRuntime2(options) {
1406
+ const bypassSanitization = options?.contentSecurity?.bypassSanitization;
1407
+ const allowInlineScripts = bypassSanitization || options?.contentSecurity?.allowInlineScripts;
1408
+ return `
1409
+ // Universal Renderers (Vendor)
1410
+ (function() {
1411
+ var renderers = {};
1412
+
1413
+ // XSS protection settings (configured at build time)
1414
+ // Set to true if contentSecurity.allowInlineScripts or bypassSanitization is enabled
1415
+ var __allowInlineScripts = ${allowInlineScripts ? "true" : "false"};
1416
+
1417
+ renderers.html = {
1418
+ type: 'html',
1419
+ priority: 0,
1420
+ canHandle: function(c) { return c.type === 'html'; },
1421
+ render: function(c, ctx) {
1422
+ var html = c.source;
1423
+ // Apply XSS protection unless bypassed
1424
+ if (!__allowInlineScripts) {
1425
+ // Remove script tags and event handlers to prevent XSS
1426
+ html = html.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');
1427
+ html = html.replace(/\\s+on\\w+\\s*=/gi, ' data-removed-handler=');
1428
+ }
1429
+ return React.createElement('div', {
1430
+ className: 'frontmcp-html-content',
1431
+ dangerouslySetInnerHTML: { __html: html }
1432
+ });
1433
+ }
1434
+ };
1435
+
1436
+ renderers.markdown = {
1437
+ type: 'markdown',
1438
+ priority: 10,
1439
+ canHandle: function(c) {
1440
+ if (c.type === 'markdown') return true;
1441
+ if (typeof c.source !== 'string') return false;
1442
+ var s = c.source;
1443
+ return /^#{1,6}\\s/m.test(s) || /^[-*]\\s/m.test(s) || /\\*\\*[^*]+\\*\\*/.test(s);
1444
+ },
1445
+ render: function(c, ctx) {
1446
+ if (window.ReactMarkdown) {
1447
+ return React.createElement(window.ReactMarkdown, {
1448
+ children: c.source,
1449
+ components: Object.assign({}, ctx.components, c.components)
1450
+ });
1451
+ }
1452
+ var html = window.__frontmcp.parseMarkdown ? window.__frontmcp.parseMarkdown(c.source) : c.source;
1453
+ return React.createElement('div', {
1454
+ className: 'frontmcp-markdown prose',
1455
+ dangerouslySetInnerHTML: { __html: html }
1456
+ });
1457
+ }
1458
+ };
1459
+
1460
+ renderers.react = {
1461
+ type: 'react',
1462
+ priority: 30,
1463
+ canHandle: function(c) { return c.type === 'react' || typeof c.source === 'function'; },
1464
+ render: function(c, ctx) {
1465
+ var Component = c.source;
1466
+ var props = Object.assign({
1467
+ output: ctx.output,
1468
+ input: ctx.input,
1469
+ state: ctx.state,
1470
+ data: ctx.output // Alias for convenience
1471
+ }, c.props);
1472
+ return React.createElement(Component, props);
1473
+ }
1474
+ };
1475
+
1476
+ renderers.mdx = {
1477
+ type: 'mdx',
1478
+ priority: 20,
1479
+ canHandle: function(c) {
1480
+ if (c.type === 'mdx') return true;
1481
+ if (typeof c.source !== 'string') return false;
1482
+ var s = c.source;
1483
+ return /<[A-Z][a-zA-Z]*/.test(s) && /^#{1,6}\\s/m.test(s);
1484
+ },
1485
+ render: function(c, ctx) {
1486
+ if (typeof c.compiledContent === 'function') {
1487
+ var MDXContent = c.compiledContent;
1488
+ return React.createElement(MDXContent, {
1489
+ output: ctx.output,
1490
+ input: ctx.input,
1491
+ components: Object.assign({}, ctx.components, c.components)
1492
+ });
1493
+ }
1494
+ return React.createElement('div', { className: 'frontmcp-mdx-fallback' }, [
1495
+ React.createElement('div', {
1496
+ key: 'warn',
1497
+ className: 'bg-yellow-50 border border-yellow-200 rounded p-2 mb-2 text-sm text-yellow-800'
1498
+ }, 'MDX requires pre-compilation. Showing raw content.'),
1499
+ React.createElement('pre', {
1500
+ key: 'pre',
1501
+ className: 'bg-gray-100 p-4 rounded text-sm overflow-auto'
1502
+ }, c.source)
1503
+ ]);
1504
+ }
1505
+ };
1506
+
1507
+ var sortedRenderers = [renderers.react, renderers.mdx, renderers.markdown, renderers.html];
1508
+
1509
+ window.__frontmcp.detectRenderer = function(content) {
1510
+ if (content.type && renderers[content.type]) {
1511
+ return renderers[content.type];
1512
+ }
1513
+ for (var i = 0; i < sortedRenderers.length; i++) {
1514
+ if (sortedRenderers[i].canHandle(content)) {
1515
+ return sortedRenderers[i];
1516
+ }
1517
+ }
1518
+ return renderers.html;
1519
+ };
1520
+
1521
+ window.__frontmcp.renderContent = function(content, context) {
1522
+ var renderer = window.__frontmcp.detectRenderer(content);
1523
+ return renderer.render(content, context);
1524
+ };
1525
+
1526
+ window.__frontmcp.renderers = renderers;
1527
+ })();
1528
+ `;
1529
+ }
1530
+ function buildUIComponentsRuntime() {
1531
+ return (0, import_build.buildUIComponentsRuntime)();
1532
+ }
1533
+ function buildUniversalAppRuntime2() {
1534
+ return `
1535
+ // Universal App (Vendor)
1536
+ (function() {
1537
+ var LoadingSpinner = function() {
1538
+ return React.createElement('div', {
1539
+ className: 'frontmcp-loading flex items-center justify-center min-h-[200px]'
1540
+ }, React.createElement('div', {
1541
+ className: 'frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin'
1542
+ }));
1543
+ };
1544
+
1545
+ var ErrorDisplay = function(props) {
1546
+ return React.createElement('div', {
1547
+ className: 'frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800'
1548
+ }, [
1549
+ React.createElement('div', { key: 'title', className: 'font-medium' }, 'Error'),
1550
+ React.createElement('div', { key: 'msg', className: 'text-sm mt-1' }, props.error)
1551
+ ]);
1552
+ };
1553
+
1554
+ var EmptyState = function() {
1555
+ return React.createElement('div', {
1556
+ className: 'frontmcp-empty text-gray-500 text-center py-8'
1557
+ }, 'No content to display');
1558
+ };
1559
+
1560
+ window.__frontmcp.UniversalApp = function(props) {
1561
+ var state = window.useFrontMCPStore();
1562
+
1563
+ if (state.loading) {
1564
+ return props.fallback || React.createElement(LoadingSpinner);
1565
+ }
1566
+
1567
+ if (state.error) {
1568
+ var ErrorComp = props.errorFallback || ErrorDisplay;
1569
+ return React.createElement(ErrorComp, { error: state.error });
1570
+ }
1571
+
1572
+ var content = props.content || state.content;
1573
+
1574
+ if (!content) {
1575
+ return React.createElement(EmptyState);
1576
+ }
1577
+
1578
+ var context = {
1579
+ output: state.output,
1580
+ input: state.input,
1581
+ state: state,
1582
+ components: props.components || {}
1583
+ };
1584
+
1585
+ var rendered = window.__frontmcp.renderContent(content, context);
1586
+ return React.createElement('div', { className: 'frontmcp-content' }, rendered);
1587
+ };
1588
+
1589
+ window.__frontmcp.LoadingSpinner = LoadingSpinner;
1590
+ window.__frontmcp.ErrorDisplay = ErrorDisplay;
1591
+ window.__frontmcp.EmptyState = EmptyState;
1592
+ })();
1593
+ `;
1594
+ }
1595
+ function buildComponentWrapper() {
1596
+ return `
1597
+ // Component Execution (App Chunk)
1598
+ (function() {
1599
+ ${RUNTIME_PLACEHOLDERS.COMPONENT_CODE}
1600
+ })();
1601
+ `;
1602
+ }
1603
+ function buildDataInjectionWrapper() {
1604
+ return `
1605
+ // Data Injection (App Chunk)
1606
+ (function() {
1607
+ ${RUNTIME_PLACEHOLDERS.DATA_INJECTION}
1608
+ })();
1609
+ `;
1610
+ }
1611
+ function buildCustomComponentsWrapper() {
1612
+ return `
1613
+ // Custom Components (App Chunk)
1614
+ (function() {
1615
+ ${RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS}
1616
+ })();
1617
+ `;
1618
+ }
1619
+ function buildCdnImports2(options) {
1620
+ const parts = [];
1621
+ if (options.cdnType === "esm") {
1622
+ if (options.includeMarkdown) {
1623
+ parts.push(`
1624
+ <script type="module">
1625
+ import ReactMarkdown from '${UNIVERSAL_CDN.esm.reactMarkdown}';
1626
+ window.ReactMarkdown = ReactMarkdown;
1627
+ </script>`);
1628
+ }
1629
+ if (options.includeMdx) {
1630
+ parts.push(`
1631
+ <script type="module">
1632
+ import { MDXProvider } from '${UNIVERSAL_CDN.esm.mdxReact}';
1633
+ window.MDXProvider = MDXProvider;
1634
+ </script>`);
1635
+ }
1636
+ }
1637
+ return parts.join("\n");
1638
+ }
1639
+ function getCachedRuntime(options, config = {}) {
1640
+ const cacheKey = generateCacheKey(options);
1641
+ const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...config };
1642
+ const cached = runtimeCache.get(cacheKey);
1643
+ if (cached) {
1644
+ if (cacheConfig.ttl === 0 || Date.now() - cached.cachedAt < cacheConfig.ttl) {
1645
+ return {
1646
+ vendorScript: cached.script,
1647
+ appTemplate: buildAppTemplate(),
1648
+ cdnImports: cached.cdnImports,
1649
+ vendorSize: cached.size,
1650
+ cached: true,
1651
+ cacheKey
1652
+ };
1653
+ }
1654
+ runtimeCache.delete(cacheKey);
1655
+ }
1656
+ const vendorParts = [];
1657
+ if (options.includeBridge) {
1658
+ vendorParts.push((0, import_runtime.getMCPBridgeScript)());
1659
+ }
1660
+ vendorParts.push(buildStoreRuntime2(), buildRequireShim());
1661
+ if (options.cdnType === "umd" || options.includeMarkdown) {
1662
+ vendorParts.push(buildInlineMarkdownParser2(options));
1663
+ }
1664
+ vendorParts.push(buildRenderersRuntime2(options));
1665
+ vendorParts.push(buildUIComponentsRuntime());
1666
+ vendorParts.push(buildUniversalAppRuntime2());
1667
+ let vendorScript = vendorParts.join("\n");
1668
+ if (options.minify) {
1669
+ vendorScript = minifyScript(vendorScript);
1670
+ }
1671
+ const cdnImports = buildCdnImports2(options);
1672
+ const entry = {
1673
+ script: vendorScript,
1674
+ cdnImports,
1675
+ size: vendorScript.length,
1676
+ cacheKey,
1677
+ cachedAt: Date.now()
1678
+ };
1679
+ if (runtimeCache.size >= cacheConfig.maxEntries) {
1680
+ const oldestKey = runtimeCache.keys().next().value;
1681
+ if (oldestKey) {
1682
+ runtimeCache.delete(oldestKey);
1683
+ }
1684
+ }
1685
+ runtimeCache.set(cacheKey, entry);
1686
+ return {
1687
+ vendorScript,
1688
+ appTemplate: buildAppTemplate(),
1689
+ cdnImports,
1690
+ vendorSize: vendorScript.length,
1691
+ cached: false,
1692
+ cacheKey
1693
+ };
1694
+ }
1695
+ function buildAppTemplate() {
1696
+ return [buildCustomComponentsWrapper(), buildComponentWrapper(), buildDataInjectionWrapper()].join("\n");
1697
+ }
1698
+ function minifyScript(script) {
1699
+ return script.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1700
+ }
1701
+ function clearRuntimeCache() {
1702
+ runtimeCache.clear();
1703
+ }
1704
+ function getRuntimeCacheStats() {
1705
+ let totalSize = 0;
1706
+ const keys = [];
1707
+ for (const [key, entry] of runtimeCache) {
1708
+ keys.push(key);
1709
+ totalSize += entry.size;
1710
+ }
1711
+ return {
1712
+ entries: runtimeCache.size,
1713
+ totalSize,
1714
+ keys
1715
+ };
1716
+ }
1717
+ function buildAppScript(appTemplate, componentCode, dataInjection, customComponents = "") {
1718
+ 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);
1719
+ }
1720
+ var DEFAULT_OUTPUT_PLACEHOLDER = "__FRONTMCP_OUTPUT_PLACEHOLDER__";
1721
+ var DEFAULT_INPUT_PLACEHOLDER = "__FRONTMCP_INPUT_PLACEHOLDER__";
1722
+ function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, options) {
1723
+ const buildMode = options?.buildMode ?? "static";
1724
+ const cdnType = options?.cdnType ?? "esm";
1725
+ switch (buildMode) {
1726
+ case "dynamic":
1727
+ return buildDynamicDataInjectionCode(
1728
+ toolName,
1729
+ input,
1730
+ output,
1731
+ structuredContent,
1732
+ contentType,
1733
+ source,
1734
+ hasComponent,
1735
+ cdnType,
1736
+ options?.dynamicOptions
1737
+ );
1738
+ case "hybrid":
1739
+ return buildHybridDataInjectionCode(
1740
+ toolName,
1741
+ structuredContent,
1742
+ contentType,
1743
+ source,
1744
+ hasComponent,
1745
+ options?.hybridOptions
1746
+ );
1747
+ default:
1748
+ return buildStaticDataInjectionCode(
1749
+ toolName,
1750
+ input,
1751
+ output,
1752
+ structuredContent,
1753
+ contentType,
1754
+ source,
1755
+ hasComponent
1756
+ );
1757
+ }
1758
+ }
1759
+ function buildStaticDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
1760
+ const safeJson = (value) => {
1761
+ try {
1762
+ return JSON.stringify(value);
1763
+ } catch {
1764
+ return "null";
1765
+ }
1766
+ };
1767
+ if (hasComponent) {
1768
+ return `
1769
+ // Static Mode - Data baked at build time
1770
+ window.__frontmcp.setState({
1771
+ toolName: ${safeJson(toolName)},
1772
+ input: ${safeJson(input ?? null)},
1773
+ output: ${safeJson(output ?? null)},
1774
+ structuredContent: ${safeJson(structuredContent ?? null)},
1775
+ content: {
1776
+ type: 'react',
1777
+ source: window.__frontmcp_component
1778
+ },
1779
+ loading: false,
1780
+ error: null
1781
+ });`;
1782
+ }
1783
+ return `
1784
+ // Static Mode - Data baked at build time
1785
+ window.__frontmcp.setState({
1786
+ toolName: ${safeJson(toolName)},
1787
+ input: ${safeJson(input ?? null)},
1788
+ output: ${safeJson(output ?? null)},
1789
+ structuredContent: ${safeJson(structuredContent ?? null)},
1790
+ content: {
1791
+ type: ${safeJson(contentType)},
1792
+ source: ${safeJson(source)}
1793
+ },
1794
+ loading: false,
1795
+ error: null
1796
+ });`;
1797
+ }
1798
+ function buildDynamicDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, cdnType, dynamicOptions) {
1799
+ if (cdnType === "umd") {
1800
+ return buildDynamicWithPlaceholdersCode(
1801
+ toolName,
1802
+ structuredContent,
1803
+ contentType,
1804
+ source,
1805
+ hasComponent,
1806
+ dynamicOptions
1807
+ );
1808
+ }
1809
+ return buildDynamicWithSubscriptionCode(
1810
+ toolName,
1811
+ input,
1812
+ output,
1813
+ structuredContent,
1814
+ contentType,
1815
+ source,
1816
+ hasComponent,
1817
+ dynamicOptions
1818
+ );
1819
+ }
1820
+ function buildDynamicWithPlaceholdersCode(toolName, structuredContent, contentType, source, hasComponent, dynamicOptions) {
1821
+ const safeJson = (value) => {
1822
+ try {
1823
+ return JSON.stringify(value);
1824
+ } catch {
1825
+ return "null";
1826
+ }
1827
+ };
1828
+ const outputPlaceholder = DEFAULT_OUTPUT_PLACEHOLDER;
1829
+ const inputPlaceholder = DEFAULT_INPUT_PLACEHOLDER;
1830
+ const includeInitialData = dynamicOptions?.includeInitialData ?? true;
1831
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1832
+ return `
1833
+ // Dynamic Mode - Placeholder-based for non-OpenAI platforms
1834
+ var __outputRaw = "${outputPlaceholder}";
1835
+ var __inputRaw = "${inputPlaceholder}";
1836
+ var __output = null;
1837
+ var __input = null;
1838
+ var __error = null;
1839
+ var __outputNotReplaced = false;
1840
+ var __includeInitialData = ${includeInitialData};
1841
+
1842
+ // Parse output placeholder
1843
+ if (typeof __outputRaw === 'string' && __outputRaw !== "${outputPlaceholder}") {
1844
+ try { __output = JSON.parse(__outputRaw); } catch (e) {
1845
+ console.warn('[FrontMCP] Failed to parse output:', e);
1846
+ __error = 'Failed to parse output data';
1847
+ }
1848
+ } else if (__outputRaw === "${outputPlaceholder}") {
1849
+ __outputNotReplaced = true;
1850
+ }
1851
+
1852
+ // Parse input placeholder
1853
+ if (typeof __inputRaw === 'string' && __inputRaw !== "${inputPlaceholder}") {
1854
+ try { __input = JSON.parse(__inputRaw); } catch (e) { console.warn('[FrontMCP] Failed to parse input:', e); }
1855
+ }
1856
+
1857
+ // Handle placeholder not replaced - show error if expecting initial data
1858
+ if (__outputNotReplaced && __includeInitialData) {
1859
+ __error = 'No data provided. The output placeholder was not replaced.';
1860
+ }
1861
+
1862
+ window.__frontmcp.setState({
1863
+ toolName: ${safeJson(toolName)},
1864
+ input: __input,
1865
+ output: __output,
1866
+ structuredContent: ${safeJson(structuredContent ?? null)},
1867
+ ${contentBlock},
1868
+ loading: !__includeInitialData && __output === null && !__error,
1869
+ error: __error
1870
+ });`;
1871
+ }
1872
+ function buildDynamicWithSubscriptionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, dynamicOptions) {
1873
+ const safeJson = (value) => {
1874
+ try {
1875
+ return JSON.stringify(value);
1876
+ } catch {
1877
+ return "null";
1878
+ }
1879
+ };
1880
+ const includeInitialData = dynamicOptions?.includeInitialData ?? true;
1881
+ const subscribeToUpdates = dynamicOptions?.subscribeToUpdates ?? true;
1882
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1883
+ const initialState = includeInitialData ? `{
1884
+ toolName: ${safeJson(toolName)},
1885
+ input: ${safeJson(input ?? null)},
1886
+ output: ${safeJson(output ?? null)},
1887
+ structuredContent: ${safeJson(structuredContent ?? null)},
1888
+ ${contentBlock},
1889
+ loading: false,
1890
+ error: null
1891
+ }` : `{
1892
+ toolName: ${safeJson(toolName)},
1893
+ input: ${safeJson(input ?? null)},
1894
+ output: null,
1895
+ structuredContent: ${safeJson(structuredContent ?? null)},
1896
+ ${contentBlock},
1897
+ loading: true,
1898
+ error: null
1899
+ }`;
1900
+ const subscriptionBlock = subscribeToUpdates ? `
1901
+ // Subscribe to platform tool result events
1902
+ (function() {
1903
+ function subscribeToUpdates() {
1904
+ if (window.openai && window.openai.canvas && window.openai.canvas.onToolResult) {
1905
+ window.openai.canvas.onToolResult(function(result) {
1906
+ window.__frontmcp.updateOutput(result);
1907
+ window.dispatchEvent(new CustomEvent('frontmcp:toolResult', { detail: result }));
1908
+ });
1909
+ }
1910
+ }
1911
+ if (document.readyState === 'loading') {
1912
+ document.addEventListener('DOMContentLoaded', subscribeToUpdates);
1913
+ } else {
1914
+ subscribeToUpdates();
1915
+ }
1916
+ })();` : "";
1917
+ return `
1918
+ // Dynamic Mode - OpenAI Subscription
1919
+ window.__frontmcp.setState(${initialState});
1920
+ ${subscriptionBlock}`;
1921
+ }
1922
+ function buildHybridDataInjectionCode(toolName, structuredContent, contentType, source, hasComponent, hybridOptions) {
1923
+ const safeJson = (value) => {
1924
+ try {
1925
+ return JSON.stringify(value);
1926
+ } catch {
1927
+ return "null";
1928
+ }
1929
+ };
1930
+ const outputPlaceholder = hybridOptions?.placeholder ?? DEFAULT_OUTPUT_PLACEHOLDER;
1931
+ const inputPlaceholder = hybridOptions?.inputPlaceholder ?? DEFAULT_INPUT_PLACEHOLDER;
1932
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1933
+ return `
1934
+ // Hybrid Mode - Placeholders replaced at runtime
1935
+ var __outputRaw = "${outputPlaceholder}";
1936
+ var __inputRaw = "${inputPlaceholder}";
1937
+ var __output = null;
1938
+ var __input = null;
1939
+ var __error = null;
1940
+ var __outputNotReplaced = false;
1941
+
1942
+ // Parse output placeholder
1943
+ if (typeof __outputRaw === 'string' && __outputRaw !== "${outputPlaceholder}") {
1944
+ try { __output = JSON.parse(__outputRaw); } catch (e) {
1945
+ console.warn('[FrontMCP] Failed to parse output:', e);
1946
+ __error = 'Failed to parse output data';
1947
+ }
1948
+ } else if (__outputRaw === "${outputPlaceholder}") {
1949
+ // Placeholder not replaced - no data was injected
1950
+ __outputNotReplaced = true;
1951
+ }
1952
+
1953
+ // Parse input placeholder
1954
+ if (typeof __inputRaw === 'string' && __inputRaw !== "${inputPlaceholder}") {
1955
+ try { __input = JSON.parse(__inputRaw); } catch (e) { console.warn('[FrontMCP] Failed to parse input:', e); }
1956
+ }
1957
+
1958
+ // Set error if output placeholder was not replaced (no data provided)
1959
+ if (__outputNotReplaced) {
1960
+ __error = 'No data provided. The output placeholder was not replaced.';
1961
+ }
1962
+
1963
+ window.__frontmcp.setState({
1964
+ toolName: ${safeJson(toolName)},
1965
+ input: __input,
1966
+ output: __output,
1967
+ structuredContent: ${safeJson(structuredContent ?? null)},
1968
+ ${contentBlock},
1969
+ loading: false,
1970
+ error: __error
1971
+ });`;
1972
+ }
1973
+ function buildComponentCode(transpiledCode) {
1974
+ return `
1975
+ // CommonJS module shim
1976
+ var module = { exports: {} };
1977
+ var exports = module.exports;
1978
+
1979
+ // Execute transpiled component
1980
+ ${transpiledCode}
1981
+
1982
+ // Capture component
1983
+ window.__frontmcp_component = module.exports.default || module.exports;`;
1984
+ }
1985
+ // Annotate the CommonJS export names for ESM import in node:
1986
+ 0 && (module.exports = {
1987
+ ComponentsProvider,
1988
+ DEFAULT_FRONTMCP_STATE,
1989
+ EmptyState,
1990
+ ErrorDisplay,
1991
+ FrontMCPProvider,
1992
+ LoadingSpinner,
1993
+ RUNTIME_PLACEHOLDERS,
1994
+ RendererRegistry,
1995
+ UNIVERSAL_CDN,
1996
+ UniversalApp,
1997
+ UniversalAppWithProvider,
1998
+ UniversalProvider,
1999
+ buildAppScript,
2000
+ buildComponentCode,
2001
+ buildDataInjectionCode,
2002
+ buildMinimalRuntime,
2003
+ buildUniversalRuntime,
2004
+ clearRuntimeCache,
2005
+ createContent,
2006
+ createFrontMCPStore,
2007
+ createMarkdownRenderer,
2008
+ createMdxRenderer,
2009
+ createStoreSelector,
2010
+ detectContentType,
2011
+ detectRenderer,
2012
+ getCachedRuntime,
2013
+ getGlobalStore,
2014
+ getRuntimeCacheStats,
2015
+ htmlRenderer,
2016
+ initializeStoreFromWindow,
2017
+ isMdxSupported,
2018
+ isReactComponent,
2019
+ markdownRenderer,
2020
+ mdxRenderer,
2021
+ reactRenderer,
2022
+ renderContent,
2023
+ rendererRegistry,
2024
+ resetGlobalStore,
2025
+ safeHtmlRenderer,
2026
+ setGlobalStore,
2027
+ useComponents,
2028
+ useContent,
2029
+ useFrontMCPContext,
2030
+ useFrontMCPContextSafe,
2031
+ useFrontMCPStore,
2032
+ useLoadingState,
2033
+ useToolInput,
2034
+ useToolName,
2035
+ useToolOutput,
2036
+ withFrontMCP
2037
+ });