@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
@@ -5,1478 +5,56 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // libs/ui/src/utils/safe-stringify.ts
34
- var init_safe_stringify = __esm({
35
- "libs/ui/src/utils/safe-stringify.ts"() {
36
- "use strict";
37
- }
38
- });
39
-
40
- // libs/ui/src/utils/escape-html.ts
41
- function escapeHtml(str) {
42
- if (str === null || str === void 0) {
43
- return "";
44
- }
45
- const s = String(str);
46
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
47
- }
48
- var init_escape_html = __esm({
49
- "libs/ui/src/utils/escape-html.ts"() {
50
- "use strict";
51
- }
52
- });
53
-
54
- // libs/ui/src/utils/index.ts
55
- var init_utils = __esm({
56
- "libs/ui/src/utils/index.ts"() {
57
- "use strict";
58
- init_safe_stringify();
59
- init_escape_html();
60
- }
61
- });
62
-
63
- // libs/ui/src/handlebars/helpers.ts
64
- function formatDate(date, format) {
65
- if (date === null || date === void 0) {
66
- return "";
67
- }
68
- let dateObj;
69
- if (date instanceof Date) {
70
- dateObj = date;
71
- } else if (typeof date === "string" || typeof date === "number") {
72
- dateObj = new Date(date);
73
- } else {
74
- return String(date);
75
- }
76
- if (isNaN(dateObj.getTime())) {
77
- return String(date);
78
- }
79
- const options = {};
80
- switch (format) {
81
- case "short":
82
- options.dateStyle = "short";
83
- break;
84
- case "medium":
85
- options.dateStyle = "medium";
86
- break;
87
- case "long":
88
- options.dateStyle = "long";
89
- break;
90
- case "full":
91
- options.dateStyle = "full";
92
- break;
93
- case "time":
94
- options.timeStyle = "short";
95
- break;
96
- case "datetime":
97
- options.dateStyle = "medium";
98
- options.timeStyle = "short";
99
- break;
100
- case "iso":
101
- return dateObj.toISOString();
102
- case "relative":
103
- return formatRelativeDate(dateObj);
104
- default:
105
- options.dateStyle = "medium";
106
- }
107
- return new Intl.DateTimeFormat("en-US", options).format(dateObj);
108
- }
109
- function formatRelativeDate(date) {
110
- const now = /* @__PURE__ */ new Date();
111
- const diffMs = now.getTime() - date.getTime();
112
- const diffSecs = Math.floor(diffMs / 1e3);
113
- const diffMins = Math.floor(diffSecs / 60);
114
- const diffHours = Math.floor(diffMins / 60);
115
- const diffDays = Math.floor(diffHours / 24);
116
- if (diffSecs < 60) {
117
- return "just now";
118
- } else if (diffMins < 60) {
119
- return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
120
- } else if (diffHours < 24) {
121
- return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
122
- } else if (diffDays < 7) {
123
- return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
124
- } else {
125
- return formatDate(date, "medium");
126
- }
127
- }
128
- function formatCurrency(amount, currency) {
129
- if (amount === null || amount === void 0) {
130
- return "";
131
- }
132
- const num = typeof amount === "number" ? amount : parseFloat(String(amount));
133
- if (isNaN(num)) {
134
- return String(amount);
135
- }
136
- return new Intl.NumberFormat("en-US", {
137
- style: "currency",
138
- currency: typeof currency === "string" ? currency : "USD"
139
- }).format(num);
140
- }
141
- function formatNumber(value, decimals) {
142
- if (value === null || value === void 0) {
143
- return "";
144
- }
145
- const num = typeof value === "number" ? value : parseFloat(String(value));
146
- if (isNaN(num)) {
147
- return String(value);
148
- }
149
- const options = {};
150
- if (typeof decimals === "number") {
151
- options.minimumFractionDigits = decimals;
152
- options.maximumFractionDigits = decimals;
153
- }
154
- return new Intl.NumberFormat("en-US", options).format(num);
155
- }
156
- function jsonEmbed(data) {
157
- const json2 = JSON.stringify(data ?? null);
158
- return json2.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
159
- }
160
- function json(data, pretty) {
161
- return JSON.stringify(data ?? null, null, pretty ? 2 : void 0);
162
- }
163
- function eq(a, b) {
164
- return a === b;
165
- }
166
- function ne(a, b) {
167
- return a !== b;
168
- }
169
- function gt(a, b) {
170
- return Number(a) > Number(b);
171
- }
172
- function gte(a, b) {
173
- return Number(a) >= Number(b);
174
- }
175
- function lt(a, b) {
176
- return Number(a) < Number(b);
177
- }
178
- function lte(a, b) {
179
- return Number(a) <= Number(b);
180
- }
181
- function and(a, b) {
182
- return Boolean(a) && Boolean(b);
183
- }
184
- function or(a, b) {
185
- return Boolean(a) || Boolean(b);
186
- }
187
- function not(value) {
188
- return !value;
189
- }
190
- function first(arr) {
191
- if (!Array.isArray(arr)) return void 0;
192
- return arr[0];
193
- }
194
- function last(arr) {
195
- if (!Array.isArray(arr)) return void 0;
196
- return arr[arr.length - 1];
197
- }
198
- function length(value) {
199
- if (Array.isArray(value)) return value.length;
200
- if (typeof value === "string") return value.length;
201
- return 0;
202
- }
203
- function includes(arr, value) {
204
- if (!Array.isArray(arr)) return false;
205
- return arr.includes(value);
206
- }
207
- function join(arr, separator) {
208
- if (!Array.isArray(arr)) return "";
209
- return arr.join(typeof separator === "string" ? separator : ", ");
210
- }
211
- function uppercase(str) {
212
- return String(str ?? "").toUpperCase();
213
- }
214
- function lowercase(str) {
215
- return String(str ?? "").toLowerCase();
216
- }
217
- function capitalize(str) {
218
- const s = String(str ?? "");
219
- return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
220
- }
221
- function truncate(str, maxLength, suffix) {
222
- const s = String(str ?? "");
223
- const len = typeof maxLength === "number" ? maxLength : 50;
224
- const suf = typeof suffix === "string" ? suffix : "...";
225
- if (s.length <= len) return s;
226
- return s.slice(0, len - suf.length) + suf;
227
- }
228
- function defaultValue(value, defaultValue2) {
229
- return value || defaultValue2;
230
- }
231
- function uniqueId(prefix) {
232
- const id = ++idCounter;
233
- return prefix ? `${prefix}-${id}` : `id-${id}`;
234
- }
235
- function resetUniqueIdCounter() {
236
- idCounter = 0;
237
- }
238
- function classNames(...classes) {
239
- return classes.filter(Boolean).map(String).join(" ");
240
- }
241
- var idCounter, builtinHelpers;
242
- var init_helpers = __esm({
243
- "libs/ui/src/handlebars/helpers.ts"() {
244
- "use strict";
245
- init_utils();
246
- idCounter = 0;
247
- builtinHelpers = {
248
- // Escaping
249
- escapeHtml,
250
- // Formatting
251
- formatDate,
252
- formatCurrency,
253
- formatNumber,
254
- json,
255
- jsonEmbed,
256
- // Comparison
257
- eq,
258
- ne,
259
- gt,
260
- gte,
261
- lt,
262
- lte,
263
- // Logical
264
- and,
265
- or,
266
- not,
267
- // Array
268
- first,
269
- last,
270
- length,
271
- includes,
272
- join,
273
- // String
274
- uppercase,
275
- lowercase,
276
- capitalize,
277
- truncate,
278
- // Utility
279
- default: defaultValue,
280
- uniqueId,
281
- classNames
282
- };
283
- }
284
- });
285
-
286
- // libs/ui/src/handlebars/expression-extractor.ts
287
- function extractExpressions(template) {
288
- const expressions = [];
289
- const lines = template.split("\n");
290
- const positionMap = buildPositionMap(template);
291
- let match;
292
- EXPRESSION_REGEX.lastIndex = 0;
293
- while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
294
- const fullExpression = match[0];
295
- const prefix = match[1];
296
- const content = match[2].trim();
297
- const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
298
- let type = "variable";
299
- let helperName;
300
- if (prefix === "/") {
301
- type = "block-close";
302
- helperName = content;
303
- } else if (prefix === "#") {
304
- type = "block";
305
- const parts = content.split(/\s+/);
306
- helperName = parts[0];
307
- } else {
308
- const parts = content.split(/\s+/);
309
- if (parts.length > 1 && !content.startsWith("(")) {
310
- const firstToken = parts[0];
311
- if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
312
- type = "helper";
313
- helperName = firstToken;
314
- }
315
- }
316
- }
317
- const paths = extractPathsFromContent(content);
318
- for (const path of paths) {
319
- expressions.push({
320
- path,
321
- fullExpression,
322
- line: position.line,
323
- column: position.column,
324
- type,
325
- helperName
326
- });
327
- }
328
- if (paths.length === 0 && type === "variable") {
329
- const cleanContent = content.trim();
330
- if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
331
- }
332
- }
333
- }
334
- return expressions;
335
- }
336
- function extractPathsFromContent(content) {
337
- const paths = [];
338
- let match;
339
- const regex = new RegExp(PATH_REGEX.source, "g");
340
- while ((match = regex.exec(content)) !== null) {
341
- paths.push(match[0]);
342
- }
343
- return paths;
344
- }
345
- function buildPositionMap(template) {
346
- const map = /* @__PURE__ */ new Map();
347
- let line = 1;
348
- let column = 1;
349
- for (let i = 0; i < template.length; i++) {
350
- map.set(i, { line, column });
351
- if (template[i] === "\n") {
352
- line++;
353
- column = 1;
354
- } else {
355
- column++;
356
- }
357
- }
358
- return map;
359
- }
360
- function extractVariablePaths(template) {
361
- const expressions = extractExpressions(template);
362
- const paths = new Set(expressions.map((e) => e.path));
363
- return Array.from(paths);
364
- }
365
- function extractOutputPaths(template) {
366
- return extractVariablePaths(template).filter((p) => p.startsWith("output."));
367
- }
368
- function extractInputPaths(template) {
369
- return extractVariablePaths(template).filter((p) => p.startsWith("input."));
370
- }
371
- function extractStructuredContentPaths(template) {
372
- return extractVariablePaths(template).filter((p) => p.startsWith("structuredContent."));
373
- }
374
- function extractAll(template) {
375
- const expressions = extractExpressions(template);
376
- const paths = [...new Set(expressions.map((e) => e.path))];
377
- return {
378
- expressions,
379
- paths,
380
- outputPaths: paths.filter((p) => p.startsWith("output.")),
381
- inputPaths: paths.filter((p) => p.startsWith("input.")),
382
- structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
383
- };
384
- }
385
- function hasVariablePaths(template) {
386
- return extractVariablePaths(template).length > 0;
387
- }
388
- function getExpressionAt(template, line, column) {
389
- const expressions = extractExpressions(template);
390
- return expressions.find((expr) => {
391
- if (expr.line !== line) return false;
392
- const exprEnd = expr.column + expr.fullExpression.length;
393
- return column >= expr.column && column <= exprEnd;
394
- });
395
- }
396
- function normalizePath(path) {
397
- return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
398
- }
399
- var EXPRESSION_REGEX, PATH_REGEX, KEYWORDS;
400
- var init_expression_extractor = __esm({
401
- "libs/ui/src/handlebars/expression-extractor.ts"() {
402
- "use strict";
403
- EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
404
- PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
405
- KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
406
- }
407
- });
408
-
409
- // libs/ui/src/handlebars/index.ts
410
- var handlebars_exports = {};
411
- __export(handlebars_exports, {
412
- HandlebarsRenderer: () => HandlebarsRenderer,
413
- and: () => and,
414
- builtinHelpers: () => builtinHelpers,
415
- capitalize: () => capitalize,
416
- classNames: () => classNames,
417
- containsHandlebars: () => containsHandlebars,
418
- createHandlebarsRenderer: () => createHandlebarsRenderer,
419
- defaultValue: () => defaultValue,
420
- eq: () => eq,
421
- escapeHtml: () => escapeHtml,
422
- extractAll: () => extractAll,
423
- extractExpressions: () => extractExpressions,
424
- extractInputPaths: () => extractInputPaths,
425
- extractOutputPaths: () => extractOutputPaths,
426
- extractStructuredContentPaths: () => extractStructuredContentPaths,
427
- extractVariablePaths: () => extractVariablePaths,
428
- first: () => first,
429
- formatCurrency: () => formatCurrency,
430
- formatDate: () => formatDate,
431
- formatNumber: () => formatNumber,
432
- getExpressionAt: () => getExpressionAt,
433
- gt: () => gt,
434
- gte: () => gte,
435
- hasVariablePaths: () => hasVariablePaths,
436
- includes: () => includes,
437
- isHandlebarsAvailable: () => isHandlebarsAvailable,
438
- join: () => join,
439
- json: () => json,
440
- jsonEmbed: () => jsonEmbed,
441
- last: () => last,
442
- length: () => length,
443
- lowercase: () => lowercase,
444
- lt: () => lt,
445
- lte: () => lte,
446
- ne: () => ne,
447
- normalizePath: () => normalizePath,
448
- not: () => not,
449
- or: () => or,
450
- renderTemplate: () => renderTemplate,
451
- resetUniqueIdCounter: () => resetUniqueIdCounter,
452
- truncate: () => truncate,
453
- uniqueId: () => uniqueId,
454
- uppercase: () => uppercase
455
- });
456
- async function loadHandlebars() {
457
- if (Handlebars !== null) {
458
- return Handlebars;
459
- }
460
- try {
461
- Handlebars = await import("handlebars");
462
- return Handlebars;
463
- } catch {
464
- throw new Error("Handlebars is required for template rendering. Install it: npm install handlebars");
465
- }
466
- }
467
- async function isHandlebarsAvailable() {
468
- try {
469
- await loadHandlebars();
470
- return true;
471
- } catch {
472
- return false;
473
- }
474
- }
475
- function createHandlebarsRenderer(options) {
476
- return new HandlebarsRenderer(options);
477
- }
478
- async function renderTemplate(template, context) {
479
- const renderer = createHandlebarsRenderer();
480
- return renderer.render(template, context);
481
- }
482
- function containsHandlebars(template) {
483
- return HandlebarsRenderer.containsHandlebars(template);
484
- }
485
- var Handlebars, HandlebarsRenderer;
486
- var init_handlebars = __esm({
487
- "libs/ui/src/handlebars/index.ts"() {
488
- "use strict";
489
- init_helpers();
490
- init_helpers();
491
- init_expression_extractor();
492
- Handlebars = null;
493
- HandlebarsRenderer = class {
494
- options;
495
- compiledTemplates = /* @__PURE__ */ new Map();
496
- initialized = false;
497
- hbs = null;
498
- constructor(options = {}) {
499
- this.options = {
500
- strict: false,
501
- autoEscape: true,
502
- ...options
503
- };
504
- }
505
- /**
506
- * Initialize the renderer with Handlebars.
507
- */
508
- async init() {
509
- if (this.initialized) return;
510
- this.hbs = await loadHandlebars();
511
- for (const [name, helper] of Object.entries(builtinHelpers)) {
512
- this.hbs.registerHelper(name, helper);
513
- }
514
- if (this.options.helpers) {
515
- for (const [name, helper] of Object.entries(this.options.helpers)) {
516
- this.hbs.registerHelper(name, helper);
517
- }
518
- }
519
- if (this.options.partials) {
520
- for (const [name, template] of Object.entries(this.options.partials)) {
521
- this.hbs.registerPartial(name, template);
522
- }
523
- }
524
- this.initialized = true;
525
- }
526
- /**
527
- * Render a Handlebars template.
528
- *
529
- * @param template - Template string
530
- * @param context - Render context with input/output
531
- * @returns Rendered HTML string
532
- */
533
- async render(template, context) {
534
- await this.init();
535
- if (!this.hbs) {
536
- throw new Error("Handlebars not initialized");
537
- }
538
- let compiled = this.compiledTemplates.get(template);
539
- if (!compiled) {
540
- compiled = this.hbs.compile(template, {
541
- strict: this.options.strict,
542
- noEscape: !this.options.autoEscape
543
- });
544
- this.compiledTemplates.set(template, compiled);
545
- }
546
- const data = {
547
- input: context.input ?? {},
548
- output: context.output ?? {},
549
- structuredContent: context.structuredContent,
550
- // Also expose at root level for convenience
551
- ...context.input,
552
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
553
- };
554
- try {
555
- return compiled(data);
556
- } catch (error) {
557
- throw new Error(`Template rendering failed: ${error instanceof Error ? error.message : String(error)}`);
558
- }
559
- }
560
- /**
561
- * Render a template synchronously.
562
- *
563
- * Note: Requires Handlebars to be pre-loaded. Use `render()` for async loading.
564
- *
565
- * @param template - Template string
566
- * @param context - Render context
567
- * @returns Rendered HTML string
568
- */
569
- renderSync(template, context) {
570
- if (!this.initialized || !this.hbs) {
571
- throw new Error("HandlebarsRenderer not initialized. Call render() first or use initSync().");
572
- }
573
- let compiled = this.compiledTemplates.get(template);
574
- if (!compiled) {
575
- compiled = this.hbs.compile(template, {
576
- strict: this.options.strict,
577
- noEscape: !this.options.autoEscape
578
- });
579
- this.compiledTemplates.set(template, compiled);
580
- }
581
- const data = {
582
- input: context.input ?? {},
583
- output: context.output ?? {},
584
- structuredContent: context.structuredContent,
585
- ...context.input,
586
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
587
- };
588
- return compiled(data);
589
- }
590
- /**
591
- * Initialize synchronously (for environments where Handlebars is already loaded).
592
- */
593
- initSync(handlebars) {
594
- this.hbs = handlebars;
595
- for (const [name, helper] of Object.entries(builtinHelpers)) {
596
- this.hbs.registerHelper(name, helper);
597
- }
598
- if (this.options.helpers) {
599
- for (const [name, helper] of Object.entries(this.options.helpers)) {
600
- this.hbs.registerHelper(name, helper);
601
- }
602
- }
603
- if (this.options.partials) {
604
- for (const [name, template] of Object.entries(this.options.partials)) {
605
- this.hbs.registerPartial(name, template);
606
- }
607
- }
608
- this.initialized = true;
609
- }
610
- /**
611
- * Register a custom helper.
612
- *
613
- * @param name - Helper name
614
- * @param fn - Helper function
615
- */
616
- registerHelper(name, fn) {
617
- if (this.hbs) {
618
- this.hbs.registerHelper(name, fn);
619
- }
620
- if (!this.options.helpers) {
621
- this.options.helpers = {};
622
- }
623
- this.options.helpers[name] = fn;
624
- }
625
- /**
626
- * Register a partial template.
627
- *
628
- * @param name - Partial name
629
- * @param template - Partial template string
630
- */
631
- registerPartial(name, template) {
632
- if (this.hbs) {
633
- this.hbs.registerPartial(name, template);
634
- }
635
- if (!this.options.partials) {
636
- this.options.partials = {};
637
- }
638
- this.options.partials[name] = template;
639
- }
640
- /**
641
- * Clear compiled template cache.
642
- */
643
- clearCache() {
644
- this.compiledTemplates.clear();
645
- }
646
- /**
647
- * Check if a template string contains Handlebars syntax.
648
- *
649
- * @param template - Template string to check
650
- * @returns true if contains {{...}} syntax
651
- */
652
- static containsHandlebars(template) {
653
- return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
654
- }
655
- /**
656
- * Check if the renderer is initialized.
657
- */
658
- get isInitialized() {
659
- return this.initialized;
660
- }
661
- };
662
- }
663
- });
664
-
665
- // libs/ui/src/renderers/index.ts
666
- var renderers_exports = {};
667
- __export(renderers_exports, {
668
- HtmlRenderer: () => HtmlRenderer,
669
- MdxRenderer: () => MdxRenderer,
670
- ReactRenderer: () => ReactRenderer,
671
- RendererRegistry: () => RendererRegistry,
672
- TranspileCache: () => TranspileCache,
673
- buildHydrationScript: () => buildHydrationScript,
674
- buildMdxHydrationScript: () => buildMdxHydrationScript,
675
- containsJsx: () => containsJsx,
676
- containsMdxSyntax: () => containsMdxSyntax,
677
- detectTemplateType: () => detectTemplateType,
678
- executeTranspiledCode: () => executeTranspiledCode,
679
- hashCombined: () => hashCombined,
680
- hashString: () => hashString,
681
- htmlRenderer: () => htmlRenderer,
682
- isHash: () => isHash,
683
- isPlainHtml: () => isPlainHtml,
684
- isReactComponent: () => isReactComponent,
685
- isSwcAvailable: () => isSwcAvailable,
686
- isTemplateBuilderFunction: () => isTemplateBuilderFunction,
687
- mdxRenderer: () => mdxRenderer,
688
- reactRenderer: () => reactRenderer,
689
- renderCache: () => renderCache,
690
- rendererRegistry: () => rendererRegistry,
691
- transpileAndExecute: () => transpileAndExecute,
692
- transpileCache: () => transpileCache,
693
- transpileJsx: () => transpileJsx
694
- });
695
- module.exports = __toCommonJS(renderers_exports);
696
-
697
- // libs/ui/src/renderers/utils/hash.ts
698
- function hashString(source) {
699
- let hash = 2166136261;
700
- for (let i = 0; i < source.length; i++) {
701
- hash ^= source.charCodeAt(i);
702
- hash = hash * 16777619 >>> 0;
703
- }
704
- return hash.toString(36);
705
- }
706
- function hashCombined(...values) {
707
- const combined = values.map((v) => {
708
- if (typeof v === "string") return v;
709
- if (v === null) return "null";
710
- if (v === void 0) return "undefined";
711
- try {
712
- return JSON.stringify(v);
713
- } catch {
714
- return String(v);
715
- }
716
- }).join("|");
717
- return hashString(combined);
718
- }
719
- function isHash(value) {
720
- return /^[0-9a-z]{5,10}$/i.test(value);
721
- }
722
-
723
- // libs/ui/src/renderers/cache.ts
724
- var TranspileCache = class {
725
- cache = /* @__PURE__ */ new Map();
726
- maxSize;
727
- ttl;
728
- /** Cache statistics */
729
- stats = {
730
- hits: 0,
731
- misses: 0,
732
- evictions: 0
733
- };
734
- constructor(options = {}) {
735
- this.maxSize = options.maxSize ?? 500;
736
- this.ttl = options.ttl ?? 0;
737
- }
738
- /**
739
- * Get a cached transpile result by source content.
740
- *
741
- * @param source - Source code to look up
742
- * @returns Cached result or undefined if not found/expired
743
- */
744
- get(source) {
745
- const key = hashString(source);
746
- return this.getByKey(key);
747
- }
748
- /**
749
- * Get a cached transpile result by hash key.
750
- *
751
- * @param key - Hash key
752
- * @returns Cached result or undefined if not found/expired
753
- */
754
- getByKey(key) {
755
- const entry = this.cache.get(key);
756
- if (!entry) {
757
- this.stats.misses++;
758
- return void 0;
759
- }
760
- if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
761
- this.cache.delete(key);
762
- this.stats.misses++;
763
- return void 0;
764
- }
765
- this.cache.delete(key);
766
- entry.accessCount++;
767
- this.cache.set(key, entry);
768
- this.stats.hits++;
769
- return entry.value;
770
- }
771
- /**
772
- * Store a transpile result.
773
- *
774
- * @param source - Source code (used to generate key)
775
- * @param value - Transpile result to cache
776
- * @returns The hash key used for storage
777
- */
778
- set(source, value) {
779
- const key = hashString(source);
780
- this.setByKey(key, value);
781
- return key;
782
- }
783
- /**
784
- * Store a transpile result by hash key.
785
- *
786
- * @param key - Hash key
787
- * @param value - Transpile result to cache
788
- */
789
- setByKey(key, value) {
790
- if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
791
- const oldestKey = this.cache.keys().next().value;
792
- if (oldestKey) {
793
- this.cache.delete(oldestKey);
794
- this.stats.evictions++;
795
- }
796
- }
797
- this.cache.set(key, {
798
- value,
799
- timestamp: Date.now(),
800
- accessCount: 1
801
- });
802
- }
803
- /**
804
- * Check if a source is cached.
805
- *
806
- * @param source - Source code to check
807
- * @returns True if cached and not expired
808
- */
809
- has(source) {
810
- const key = hashString(source);
811
- return this.hasByKey(key);
812
- }
813
- /**
814
- * Check if a key is cached.
815
- *
816
- * @param key - Hash key to check
817
- * @returns True if cached and not expired
818
- */
819
- hasByKey(key) {
820
- const entry = this.cache.get(key);
821
- if (!entry) return false;
822
- if (this.ttl > 0 && Date.now() - entry.timestamp > this.ttl) {
823
- this.cache.delete(key);
824
- return false;
825
- }
826
- return true;
827
- }
828
- /**
829
- * Delete a cached entry by source.
830
- *
831
- * @param source - Source code to delete
832
- * @returns True if entry was deleted
833
- */
834
- delete(source) {
835
- const key = hashString(source);
836
- return this.cache.delete(key);
837
- }
838
- /**
839
- * Clear all cached entries.
840
- */
841
- clear() {
842
- this.cache.clear();
843
- this.stats = { hits: 0, misses: 0, evictions: 0 };
844
- }
845
- /**
846
- * Get current cache size.
847
- */
848
- get size() {
849
- return this.cache.size;
850
- }
851
- /**
852
- * Get cache statistics.
853
- */
854
- getStats() {
855
- const total = this.stats.hits + this.stats.misses;
856
- return {
857
- ...this.stats,
858
- size: this.cache.size,
859
- hitRate: total > 0 ? this.stats.hits / total : 0
860
- };
861
- }
862
- };
863
- var transpileCache = new TranspileCache({ maxSize: 500 });
864
- var renderCache = new TranspileCache({
865
- maxSize: 1e3,
866
- ttl: 5 * 60 * 1e3
867
- // 5 minutes
868
- });
869
- var ComponentCache = class {
870
- cache = /* @__PURE__ */ new Map();
871
- maxSize;
872
- constructor(maxSize = 200) {
873
- this.maxSize = maxSize;
874
- }
875
- get(key) {
876
- const entry = this.cache.get(key);
877
- if (!entry) return void 0;
878
- this.cache.delete(key);
879
- this.cache.set(key, entry);
880
- return entry.value;
881
- }
882
- set(key, value) {
883
- if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
884
- const oldestKey = this.cache.keys().next().value;
885
- if (oldestKey) {
886
- this.cache.delete(oldestKey);
887
- }
888
- }
889
- this.cache.set(key, { value, timestamp: Date.now() });
890
- }
891
- has(key) {
892
- return this.cache.has(key);
893
- }
894
- delete(key) {
895
- return this.cache.delete(key);
896
- }
897
- clear() {
898
- this.cache.clear();
899
- }
900
- get size() {
901
- return this.cache.size;
902
- }
903
- };
904
- var componentCache = new ComponentCache();
905
-
906
- // libs/ui/src/theme/platforms.ts
907
- var OPENAI_PLATFORM = {
908
- id: "openai",
909
- name: "OpenAI",
910
- supportsWidgets: true,
911
- supportsTailwind: true,
912
- supportsHtmx: true,
913
- networkMode: "full",
914
- scriptStrategy: "cdn",
915
- options: {
916
- sdk: "apps-sdk",
917
- version: "1.0"
918
- }
919
- };
920
- var CLAUDE_PLATFORM = {
921
- id: "claude",
922
- name: "Claude (Artifacts)",
923
- supportsWidgets: true,
924
- supportsTailwind: true,
925
- supportsHtmx: false,
926
- // Network blocked, HTMX won't work for API calls
927
- networkMode: "blocked",
928
- scriptStrategy: "inline",
929
- maxInlineSize: 100 * 1024,
930
- // 100KB limit for artifacts
931
- cspRestrictions: ["script-src 'unsafe-inline'", "connect-src 'none'"],
932
- options: {
933
- mode: "artifacts",
934
- framework: "react"
935
- // Claude artifacts prefer React
936
- }
937
- };
938
-
939
- // libs/ui/src/renderers/utils/detect.ts
940
- function isReactComponent(value) {
941
- if (typeof value !== "function") {
942
- return false;
943
- }
944
- const fn = value;
945
- const typeofSymbol = fn.$$typeof;
946
- if (typeofSymbol) {
947
- const symbolString = typeofSymbol.toString();
948
- return symbolString.includes("react.memo") || symbolString.includes("react.forward_ref") || symbolString.includes("react.lazy");
949
- }
950
- if (fn.prototype?.isReactComponent) {
951
- return true;
952
- }
953
- if (fn.name && /^[A-Z]/.test(fn.name)) {
954
- return true;
955
- }
956
- return false;
957
- }
958
- function isTemplateBuilderFunction(fn) {
959
- if (isReactComponent(fn)) {
960
- return false;
961
- }
962
- if (fn.name && /^[A-Z]/.test(fn.name)) {
963
- return false;
964
- }
965
- return true;
966
- }
967
- function containsJsx(source) {
968
- if (/<[A-Z][a-zA-Z0-9]*(\s|>|\/)/.test(source)) {
969
- return true;
970
- }
971
- if (/<[A-Z][a-zA-Z0-9]*[^>]*\/>/.test(source)) {
972
- return true;
973
- }
974
- if (/<[a-z]+[^>]*\{[^}]+\}/.test(source)) {
975
- return true;
976
- }
977
- if (/\s(className|onClick|onChange|onSubmit|htmlFor)=/.test(source)) {
978
- return true;
979
- }
980
- if (/<>|<\/>|<React\.Fragment>/.test(source)) {
981
- return true;
982
- }
983
- if (/=>\s*\(?\s*</.test(source)) {
984
- return true;
985
- }
986
- if (/return\s*\(?\s*</.test(source)) {
987
- return true;
988
- }
989
- return false;
990
- }
991
- function containsMdxSyntax(source) {
992
- if (/<[A-Z][a-zA-Z0-9]*/.test(source)) {
993
- return true;
994
- }
995
- if (/^(import|export)\s/m.test(source)) {
996
- return true;
997
- }
998
- if (/\s(className|onClick|onChange|onSubmit|htmlFor|dangerouslySetInnerHTML)=/.test(source)) {
999
- return true;
1000
- }
1001
- if (/\{[^}"'\n]*\}/.test(source) && !/=\s*["'][^"']*\{/.test(source)) {
1002
- return true;
1003
- }
1004
- if (/^---[\s\S]*?---/m.test(source)) {
1005
- return true;
1006
- }
1007
- if (/<>|<\/>/.test(source)) {
1008
- return true;
1009
- }
1010
- return false;
1011
- }
1012
- function isPlainHtml(source) {
1013
- return !containsJsx(source) && !containsMdxSyntax(source);
1014
- }
1015
- function detectTemplateType(template) {
1016
- if (typeof template === "function") {
1017
- if (isReactComponent(template)) {
1018
- return {
1019
- type: "react",
1020
- confidence: 0.9,
1021
- reason: "Function detected as React component (PascalCase name or React symbols)"
1022
- };
1023
- }
1024
- return {
1025
- type: "html-function",
1026
- confidence: 0.8,
1027
- reason: "Function assumed to be HTML template builder"
1028
- };
1029
- }
1030
- if (typeof template === "string") {
1031
- if (containsMdxSyntax(template)) {
1032
- const hasMarkdown = /^#{1,6}\s|^\*\s|^\d+\.\s|^-\s/m.test(template);
1033
- if (hasMarkdown) {
1034
- return {
1035
- type: "mdx",
1036
- confidence: 0.9,
1037
- reason: "String contains Markdown with JSX components"
1038
- };
1039
- }
1040
- return {
1041
- type: "jsx-string",
1042
- confidence: 0.8,
1043
- reason: "String contains JSX syntax"
1044
- };
1045
- }
1046
- if (containsJsx(template)) {
1047
- return {
1048
- type: "jsx-string",
1049
- confidence: 0.85,
1050
- reason: "String contains JSX component tags or expressions"
1051
- };
1052
- }
1053
- return {
1054
- type: "html-string",
1055
- confidence: 1,
1056
- reason: "Plain HTML string"
1057
- };
1058
- }
1059
- return {
1060
- type: "html-string",
1061
- confidence: 0.5,
1062
- reason: "Unknown template type, defaulting to HTML"
1063
- };
1064
- }
1065
-
1066
- // libs/ui/src/renderers/html.renderer.ts
1067
- var handlebarsRenderer = null;
1068
- async function loadHandlebarsRenderer() {
1069
- if (handlebarsRenderer !== null) {
1070
- return handlebarsRenderer;
1071
- }
1072
- try {
1073
- const handlebarsModule = await Promise.resolve().then(() => (init_handlebars(), handlebars_exports));
1074
- const { HandlebarsRenderer: HandlebarsRenderer2 } = handlebarsModule;
1075
- const renderer = new HandlebarsRenderer2();
1076
- handlebarsRenderer = {
1077
- render: (template, context) => renderer.render(template, {
1078
- input: context.input ?? {},
1079
- output: context.output,
1080
- structuredContent: context.structuredContent
1081
- }),
1082
- containsHandlebars: (template) => HandlebarsRenderer2.containsHandlebars(template)
1083
- };
1084
- return handlebarsRenderer;
1085
- } catch {
1086
- return null;
1087
- }
1088
- }
1089
- function containsHandlebars2(template) {
1090
- return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
1091
- }
1092
- var HtmlRenderer = class {
1093
- type = "html";
1094
- priority = 0;
1095
- // Lowest priority - fallback renderer
1096
- /**
1097
- * Check if this renderer can handle the given template.
1098
- *
1099
- * Accepts:
1100
- * - Any string (assumed to be HTML, with or without Handlebars)
1101
- * - Functions that are template builders (not React components)
1102
- */
1103
- canHandle(template) {
1104
- if (typeof template === "string") {
1105
- return true;
1106
- }
1107
- if (typeof template === "function") {
1108
- return isTemplateBuilderFunction(template);
1109
- }
1110
- return false;
1111
- }
1112
- /**
1113
- * Check if a template uses Handlebars syntax.
1114
- *
1115
- * @param template - Template string to check
1116
- * @returns true if template contains {{...}} syntax
1117
- */
1118
- usesHandlebars(template) {
1119
- return containsHandlebars2(template);
1120
- }
1121
- /**
1122
- * Transpile the template.
1123
- *
1124
- * For HTML templates, no transpilation is needed.
1125
- * This method returns a dummy result for consistency.
1126
- */
1127
- async transpile(template, _options) {
1128
- const source = typeof template === "string" ? template : template.toString();
1129
- const hash = hashString(source);
1130
- return {
1131
- code: "",
1132
- // No transpiled code needed
1133
- hash,
1134
- cached: true
1135
- // Always "cached" since no work is done
1136
- };
1137
- }
1138
- /**
1139
- * Render the template to HTML string.
1140
- *
1141
- * For static strings without Handlebars, returns the string directly.
1142
- * For strings with Handlebars syntax, processes with HandlebarsRenderer.
1143
- * For functions, calls the function with the context.
1144
- */
1145
- async render(template, context, _options) {
1146
- if (typeof template === "string") {
1147
- if (containsHandlebars2(template)) {
1148
- return this.renderHandlebars(template, context);
1149
- }
1150
- return template;
1151
- }
1152
- if (typeof template === "function") {
1153
- const result = template(context);
1154
- if (typeof result === "string" && containsHandlebars2(result)) {
1155
- return this.renderHandlebars(result, context);
1156
- }
1157
- return result;
1158
- }
1159
- return String(template);
1160
- }
1161
- /**
1162
- * Render Handlebars template with context.
1163
- */
1164
- async renderHandlebars(template, context) {
1165
- const renderer = await loadHandlebarsRenderer();
1166
- if (!renderer) {
1167
- console.warn(
1168
- "[@frontmcp/ui] Template contains Handlebars syntax but handlebars is not installed. Install it for template interpolation: npm install handlebars"
1169
- );
1170
- return template;
1171
- }
1172
- return renderer.render(template, {
1173
- input: context.input,
1174
- output: context.output,
1175
- structuredContent: context.structuredContent
1176
- });
1177
- }
1178
- /**
1179
- * Get runtime scripts for client-side functionality.
1180
- *
1181
- * HTML templates don't need additional runtime scripts.
1182
- */
1183
- getRuntimeScripts(_platform) {
1184
- return {
1185
- headScripts: "",
1186
- isInline: false
1187
- };
1188
- }
1189
- };
1190
- var htmlRenderer = new HtmlRenderer();
1191
-
1192
- // libs/ui/src/renderers/registry.ts
1193
- var RendererRegistry = class {
1194
- renderers = /* @__PURE__ */ new Map();
1195
- sortedRenderers = [];
1196
- defaultRenderer = "html";
1197
- debug;
1198
- constructor(options = {}) {
1199
- this.debug = options.debug ?? false;
1200
- this.register(htmlRenderer);
1201
- }
1202
- /**
1203
- * Register a renderer.
1204
- *
1205
- * Renderers are sorted by priority (highest first) for detection.
1206
- *
1207
- * @param renderer - Renderer to register
1208
- */
1209
- register(renderer) {
1210
- this.renderers.set(renderer.type, renderer);
1211
- this.updateSortedList();
1212
- if (this.debug) {
1213
- console.log(`[RendererRegistry] Registered renderer: ${renderer.type} (priority: ${renderer.priority})`);
1214
- }
1215
- }
1216
- /**
1217
- * Unregister a renderer.
1218
- *
1219
- * @param type - Type of renderer to remove
1220
- * @returns True if renderer was removed
1221
- */
1222
- unregister(type) {
1223
- const removed = this.renderers.delete(type);
1224
- if (removed) {
1225
- this.updateSortedList();
1226
- }
1227
- return removed;
1228
- }
1229
- /**
1230
- * Get a renderer by type.
1231
- *
1232
- * @param type - Renderer type
1233
- * @returns Renderer or undefined if not found
1234
- */
1235
- get(type) {
1236
- return this.renderers.get(type);
1237
- }
1238
- /**
1239
- * Check if a renderer type is registered.
1240
- *
1241
- * @param type - Renderer type
1242
- * @returns True if registered
1243
- */
1244
- has(type) {
1245
- return this.renderers.has(type);
1246
- }
1247
- /**
1248
- * Get all registered renderer types.
1249
- *
1250
- * @returns Array of renderer types
1251
- */
1252
- getTypes() {
1253
- return Array.from(this.renderers.keys());
1254
- }
1255
- /**
1256
- * Auto-detect the renderer for a template.
1257
- *
1258
- * Checks renderers in priority order (highest first).
1259
- * Returns HTML renderer as fallback.
1260
- *
1261
- * @param template - Template to detect
1262
- * @returns Detection result with renderer and confidence
1263
- */
1264
- detect(template) {
1265
- for (const renderer of this.sortedRenderers) {
1266
- if (renderer.canHandle(template)) {
1267
- const result = {
1268
- renderer,
1269
- confidence: renderer.priority / 100,
1270
- // Normalize to 0-1
1271
- reason: `Matched by ${renderer.type} renderer`
1272
- };
1273
- if (this.debug) {
1274
- console.log(`[RendererRegistry] Detected template as ${renderer.type} (confidence: ${result.confidence})`);
1275
- }
1276
- return result;
1277
- }
1278
- }
1279
- const fallback = this.renderers.get(this.defaultRenderer);
1280
- if (!fallback) {
1281
- throw new Error(`Default renderer '${this.defaultRenderer}' not found`);
1282
- }
1283
- return {
1284
- renderer: fallback,
1285
- confidence: 0.5,
1286
- reason: "Fallback to default HTML renderer"
1287
- };
1288
- }
1289
- /**
1290
- * Render a template with auto-detection.
1291
- *
1292
- * @param template - Template to render (React, MDX, or HTML)
1293
- * @param context - Template context with input/output
1294
- * @param options - Render options
1295
- * @returns Rendered result with HTML and metadata
1296
- */
1297
- async render(template, context, options = {}) {
1298
- const platform = options.platform ?? OPENAI_PLATFORM;
1299
- const detection = this.detect(template);
1300
- const renderer = detection.renderer;
1301
- if (this.debug) {
1302
- console.log(`[RendererRegistry] Rendering with ${renderer.type} renderer`);
1303
- }
1304
- const transpileResult = await renderer.transpile(template);
1305
- const html = await renderer.render(template, context, options);
1306
- const runtimeScripts = renderer.getRuntimeScripts(platform);
1307
- return {
1308
- html,
1309
- rendererType: renderer.type,
1310
- transpileCached: transpileResult.cached,
1311
- runtimeScripts
1312
- };
1313
- }
1314
- /**
1315
- * Render with a specific renderer type.
1316
- *
1317
- * @param type - Renderer type to use
1318
- * @param template - Template to render
1319
- * @param context - Template context
1320
- * @param options - Render options
1321
- * @returns Rendered result
1322
- */
1323
- async renderWith(type, template, context, options = {}) {
1324
- const renderer = this.renderers.get(type);
1325
- if (!renderer) {
1326
- throw new Error(`Renderer '${type}' not registered`);
1327
- }
1328
- const platform = options.platform ?? OPENAI_PLATFORM;
1329
- const transpileResult = await renderer.transpile(template);
1330
- const html = await renderer.render(template, context, options);
1331
- const runtimeScripts = renderer.getRuntimeScripts(platform);
1332
- return {
1333
- html,
1334
- rendererType: type,
1335
- transpileCached: transpileResult.cached,
1336
- runtimeScripts
1337
- };
1338
- }
1339
- /**
1340
- * Update the sorted renderer list by priority.
1341
- */
1342
- updateSortedList() {
1343
- this.sortedRenderers = Array.from(this.renderers.values()).sort((a, b) => b.priority - a.priority);
1344
- }
1345
- /**
1346
- * Set the default renderer type.
1347
- *
1348
- * @param type - Renderer type to use as default
1349
- */
1350
- setDefault(type) {
1351
- if (!this.renderers.has(type)) {
1352
- throw new Error(`Cannot set default to unregistered renderer '${type}'`);
1353
- }
1354
- this.defaultRenderer = type;
1355
- }
1356
- /**
1357
- * Get registry statistics.
1358
- */
1359
- getStats() {
1360
- return {
1361
- registeredRenderers: this.getTypes(),
1362
- defaultRenderer: this.defaultRenderer,
1363
- priorityOrder: this.sortedRenderers.map((r) => ({
1364
- type: r.type,
1365
- priority: r.priority
1366
- }))
1367
- };
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 });
1368
17
  }
18
+ return to;
1369
19
  };
1370
- var rendererRegistry = new RendererRegistry();
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);
1371
29
 
1372
- // libs/ui/src/renderers/utils/transpiler.ts
1373
- var DEFAULT_SWC_OPTIONS = {
1374
- typescript: true,
1375
- jsx: true,
1376
- jsxRuntime: "automatic",
1377
- development: false
1378
- };
1379
- var swcTransform = null;
1380
- async function loadSwcTransform() {
1381
- if (swcTransform !== null) {
1382
- return swcTransform;
1383
- }
1384
- try {
1385
- const swc = await import("@swc/core");
1386
- swcTransform = swc.transform;
1387
- return swcTransform;
1388
- } catch {
1389
- console.warn(
1390
- "[@frontmcp/ui] @swc/core not available. Runtime JSX transpilation disabled. Install @swc/core to enable: npm install @swc/core"
1391
- );
1392
- return null;
1393
- }
1394
- }
1395
- async function transpileJsx(source, options = {}) {
1396
- const hash = hashString(source);
1397
- const cached = transpileCache.getByKey(hash);
1398
- if (cached) {
1399
- return { ...cached, cached: true };
1400
- }
1401
- const transform = await loadSwcTransform();
1402
- if (!transform) {
1403
- throw new Error(
1404
- "Runtime JSX transpilation requires @swc/core. Either install @swc/core or use pre-compiled React components."
1405
- );
1406
- }
1407
- const opts = { ...DEFAULT_SWC_OPTIONS, ...options };
1408
- const swcOptions = {
1409
- jsc: {
1410
- parser: {
1411
- syntax: opts.typescript ? "typescript" : "ecmascript",
1412
- tsx: opts.jsx,
1413
- jsx: opts.jsx
1414
- },
1415
- transform: {
1416
- react: {
1417
- runtime: opts.jsxRuntime,
1418
- development: opts.development
1419
- }
1420
- },
1421
- target: "es2020"
1422
- },
1423
- module: {
1424
- type: "commonjs"
1425
- }
1426
- };
1427
- const result = await transform(source, swcOptions);
1428
- const transpileResult = {
1429
- code: result.code,
1430
- hash,
1431
- cached: false
1432
- };
1433
- transpileCache.setByKey(hash, transpileResult);
1434
- return transpileResult;
1435
- }
1436
- async function isSwcAvailable() {
1437
- const transform = await loadSwcTransform();
1438
- return transform !== null;
30
+ // libs/ui/src/renderers/index.ts
31
+ var renderers_exports = {};
32
+ __export(renderers_exports, {
33
+ MdxRenderer: () => MdxRenderer,
34
+ ReactRenderer: () => ReactRenderer,
35
+ ReactRendererAdapter: () => ReactRendererAdapter,
36
+ createReactAdapter: () => createReactAdapter,
37
+ executeTranspiledCode: () => executeTranspiledCode,
38
+ loadReactAdapter: () => loadReactAdapter,
39
+ mdxRenderer: () => mdxRenderer,
40
+ reactRenderer: () => reactRenderer,
41
+ transpileAndExecute: () => transpileAndExecute
42
+ });
43
+ module.exports = __toCommonJS(renderers_exports);
44
+
45
+ // libs/ui/src/renderers/react.renderer.ts
46
+ var import_renderers = require("@frontmcp/uipack/renderers");
47
+ var VALID_JS_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
48
+ function isValidComponentName(name) {
49
+ return VALID_JS_IDENTIFIER.test(name);
1439
50
  }
1440
- async function executeTranspiledCode(code, context = {}) {
1441
- let React;
1442
- let jsxRuntime;
1443
- try {
1444
- React = await import("react");
1445
- jsxRuntime = await import("react/jsx-runtime");
1446
- } catch {
1447
- throw new Error("React is required for JSX templates. Install react: npm install react react-dom");
1448
- }
1449
- const exports2 = {};
1450
- const module2 = { exports: exports2 };
1451
- const require2 = (id) => {
1452
- switch (id) {
1453
- case "react":
1454
- return React;
1455
- case "react/jsx-runtime":
1456
- return jsxRuntime;
1457
- case "react/jsx-dev-runtime":
1458
- return jsxRuntime;
1459
- default:
1460
- if (context[id]) {
1461
- return context[id];
1462
- }
1463
- throw new Error(`Module '${id}' not available in JSX template context`);
1464
- }
1465
- };
1466
- try {
1467
- const fn = new Function("exports", "require", "module", "__filename", "__dirname", "React", "context", code);
1468
- fn(exports2, require2, module2, "template.js", "/", React, context);
1469
- return module2.exports["default"] || module2.exports[Object.keys(module2.exports)[0]] || module2.exports;
1470
- } catch (error) {
1471
- throw new Error(`Failed to execute transpiled JSX: ${error instanceof Error ? error.message : String(error)}`);
51
+ function sanitizeComponentName(name) {
52
+ if (isValidComponentName(name)) {
53
+ return name;
1472
54
  }
55
+ const sanitized = name.replace(/[^a-zA-Z0-9_$]/g, "_").replace(/^[0-9]/, "_$&");
56
+ return sanitized || "Component";
1473
57
  }
1474
- async function transpileAndExecute(source, context = {}) {
1475
- const result = await transpileJsx(source);
1476
- return executeTranspiledCode(result.code, context);
1477
- }
1478
-
1479
- // libs/ui/src/renderers/react.renderer.ts
1480
58
  var REACT_CDN = {
1481
59
  react: "https://esm.sh/react@19",
1482
60
  reactDom: "https://esm.sh/react-dom@19/client"
@@ -1490,13 +68,6 @@ var ReactRenderer = class {
1490
68
  type = "react";
1491
69
  priority = 20;
1492
70
  // Higher priority than HTML
1493
- /**
1494
- * Lazy-loaded React modules.
1495
- */
1496
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1497
- React = null;
1498
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1499
- ReactDOMServer = null;
1500
71
  /**
1501
72
  * Check if this renderer can handle the given template.
1502
73
  *
@@ -1505,10 +76,10 @@ var ReactRenderer = class {
1505
76
  * - Strings containing JSX syntax
1506
77
  */
1507
78
  canHandle(template) {
1508
- if (typeof template === "function" && isReactComponent(template)) {
79
+ if (typeof template === "function" && (0, import_renderers.isReactComponent)(template)) {
1509
80
  return true;
1510
81
  }
1511
- if (typeof template === "string" && containsJsx(template)) {
82
+ if (typeof template === "string" && (0, import_renderers.containsJsx)(template)) {
1512
83
  return true;
1513
84
  }
1514
85
  return false;
@@ -1521,7 +92,7 @@ var ReactRenderer = class {
1521
92
  */
1522
93
  async transpile(template, options) {
1523
94
  if (typeof template === "function") {
1524
- const hash = hashString(template.toString());
95
+ const hash = (0, import_renderers.hashString)(template.toString());
1525
96
  return {
1526
97
  code: "",
1527
98
  // No transpiled code for already-compiled components
@@ -1530,53 +101,116 @@ var ReactRenderer = class {
1530
101
  };
1531
102
  }
1532
103
  if (typeof template === "string") {
1533
- return transpileJsx(template, {
104
+ return (0, import_renderers.transpileJsx)(template, {
1534
105
  development: options?.sourceMaps ?? false
1535
106
  });
1536
107
  }
1537
108
  throw new Error("Invalid template type for ReactRenderer");
1538
109
  }
1539
110
  /**
1540
- * Render the template to HTML string using react-dom/server.
111
+ * Render the template to HTML for client-side rendering.
112
+ *
113
+ * Unlike SSR, this method generates HTML that will be rendered
114
+ * client-side by React in the browser. No server-side React required.
115
+ *
116
+ * The generated HTML includes:
117
+ * - A container div for the React root
118
+ * - The component code (transpiled if needed)
119
+ * - Props embedded as a data attribute
120
+ * - A render script that initializes the component
1541
121
  */
1542
- async render(template, context, options) {
1543
- await this.loadReact();
1544
- let Component;
122
+ async render(template, context, _options) {
123
+ const props = {
124
+ input: context.input,
125
+ output: context.output,
126
+ structuredContent: context.structuredContent,
127
+ helpers: context.helpers
128
+ };
129
+ const escapedProps = JSON.stringify(props).replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
130
+ const rootId = `frontmcp-react-${(0, import_renderers.hashString)(Date.now().toString()).slice(0, 8)}`;
131
+ let componentCode;
132
+ let componentName;
1545
133
  if (typeof template === "function") {
1546
- Component = template;
134
+ const rawName = template.name || "Component";
135
+ componentName = sanitizeComponentName(rawName);
136
+ componentCode = `
137
+ // Component should be registered via window.__frontmcp_components['${componentName}']
138
+ (function() {
139
+ if (!window.__frontmcp_components || !window.__frontmcp_components['${componentName}']) {
140
+ console.error('[FrontMCP] Component "${componentName}" not registered. Use buildHydrationScript() to register components.');
141
+ }
142
+ })();
143
+ `;
1547
144
  } else if (typeof template === "string") {
1548
145
  const transpiled = await this.transpile(template);
1549
- const cached = transpileCache.getByKey(`exec:${transpiled.hash}`);
1550
- if (cached) {
1551
- Component = cached.code;
1552
- } else {
1553
- Component = await executeTranspiledCode(transpiled.code, {
1554
- // Provide any additional MDX components if specified
1555
- ...options?.mdxComponents
1556
- });
1557
- transpileCache.setByKey(`exec:${transpiled.hash}`, {
1558
- code: Component,
1559
- hash: transpiled.hash,
1560
- cached: false
1561
- });
1562
- }
146
+ const match = transpiled.code.match(/function\s+(\w+)/);
147
+ const rawName = match?.[1] || "Widget";
148
+ componentName = sanitizeComponentName(rawName);
149
+ componentCode = transpiled.code;
1563
150
  } else {
1564
151
  throw new Error("Invalid template type for ReactRenderer");
1565
152
  }
1566
- const props = {
1567
- input: context.input,
1568
- output: context.output,
1569
- structuredContent: context.structuredContent,
1570
- helpers: context.helpers
153
+ const html = `
154
+ <div id="${rootId}" data-frontmcp-react data-component="${componentName}" data-props='${escapedProps}'>
155
+ <div class="flex items-center justify-center p-4 text-gray-500">
156
+ <svg class="animate-spin h-5 w-5 mr-2" viewBox="0 0 24 24">
157
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none"></circle>
158
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
159
+ </svg>
160
+ Loading...
161
+ </div>
162
+ </div>
163
+ <script type="module">
164
+ (function() {
165
+ ${componentCode}
166
+
167
+ // Wait for React to be available
168
+ function waitForReact(callback, maxAttempts) {
169
+ var attempts = 0;
170
+ var check = function() {
171
+ if (typeof React !== 'undefined' && typeof ReactDOM !== 'undefined') {
172
+ callback();
173
+ } else if (attempts < maxAttempts) {
174
+ attempts++;
175
+ setTimeout(check, 50);
176
+ } else {
177
+ console.error('[FrontMCP] React not loaded after ' + maxAttempts + ' attempts');
178
+ }
1571
179
  };
1572
- const element = this.React.createElement(Component, props);
1573
- const html = this.ReactDOMServer.renderToString(element);
1574
- if (options?.hydrate) {
1575
- const componentName = Component.name || "Component";
1576
- const escapedProps = JSON.stringify(props).replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1577
- return `<div data-hydrate="${componentName}" data-props='${escapedProps}'>${html}</div>`;
180
+ check();
181
+ }
182
+
183
+ waitForReact(function() {
184
+ try {
185
+ var root = document.getElementById('${rootId}');
186
+ if (!root) return;
187
+
188
+ var propsJson = root.getAttribute('data-props');
189
+ var props = propsJson ? JSON.parse(propsJson.replace(/&amp;/g, '&').replace(/&#39;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>')) : {};
190
+
191
+ // Get the component
192
+ var Component = ${componentName};
193
+
194
+ // Check if it's registered globally
195
+ if (typeof Component === 'undefined' && window.__frontmcp_components) {
196
+ Component = window.__frontmcp_components['${componentName}'];
197
+ }
198
+
199
+ if (typeof Component === 'function') {
200
+ var element = React.createElement(Component, props);
201
+ var reactRoot = ReactDOM.createRoot(root);
202
+ reactRoot.render(element);
203
+ } else {
204
+ console.error('[FrontMCP] Component "${componentName}" not found');
205
+ }
206
+ } catch (err) {
207
+ console.error('[FrontMCP] React render error:', err);
1578
208
  }
1579
- return html;
209
+ }, 100);
210
+ })();
211
+ </script>
212
+ `;
213
+ return html.trim();
1580
214
  }
1581
215
  /**
1582
216
  * Get runtime scripts for client-side functionality.
@@ -1597,60 +231,214 @@ var ReactRenderer = class {
1597
231
  isInline: false
1598
232
  };
1599
233
  }
234
+ };
235
+ var reactRenderer = new ReactRenderer();
236
+
237
+ // libs/ui/src/renderers/react.adapter.ts
238
+ var mountedRoots = /* @__PURE__ */ new WeakMap();
239
+ var ReactRendererAdapter = class {
240
+ type = "react";
241
+ // Lazy-loaded React runtime
242
+ react = null;
243
+ reactDOM = null;
244
+ loadPromise = null;
1600
245
  /**
1601
- * Load React and ReactDOMServer modules.
246
+ * Check if this adapter can handle the given content.
247
+ */
248
+ canHandle(content) {
249
+ if (typeof content === "function") {
250
+ return true;
251
+ }
252
+ if (typeof content === "string") {
253
+ return content.includes("React.createElement") || content.includes("jsx(") || content.includes("jsxs(") || /function\s+\w+\s*\([^)]*\)\s*\{[\s\S]*return\s*[\s\S]*</.test(content);
254
+ }
255
+ return false;
256
+ }
257
+ /**
258
+ * Render React component to a string.
259
+ * This is a client-side fallback - SSR should be done at build time.
260
+ */
261
+ async render(content, context, _options) {
262
+ return `<div data-frontmcp-react data-tool="${context.toolName}">${content}</div>`;
263
+ }
264
+ /**
265
+ * Render React component directly to the DOM.
266
+ */
267
+ async renderToDOM(content, target, context, options) {
268
+ try {
269
+ await this.ensureReactLoaded();
270
+ if (!this.react || !this.reactDOM) {
271
+ throw new Error("React runtime not available");
272
+ }
273
+ const componentName = target.getAttribute("data-component");
274
+ const component = this.getComponent(componentName, content);
275
+ if (!component) {
276
+ target.innerHTML = content;
277
+ return { success: true };
278
+ }
279
+ const element = this.react.createElement(component, {
280
+ input: context.input,
281
+ output: context.output,
282
+ structuredContent: context.structuredContent,
283
+ toolName: context.toolName
284
+ });
285
+ if (options?.hydrate && this.reactDOM.hydrateRoot) {
286
+ const root = this.reactDOM.hydrateRoot(target, element);
287
+ mountedRoots.set(target, root);
288
+ } else if (this.reactDOM.createRoot) {
289
+ const root = this.reactDOM.createRoot(target);
290
+ root.render(element);
291
+ mountedRoots.set(target, root);
292
+ } else if (this.reactDOM.render) {
293
+ this.reactDOM.render(element, target);
294
+ mountedRoots.set(target, {
295
+ unmount: () => this.reactDOM?.unmountComponentAtNode?.(target)
296
+ });
297
+ } else {
298
+ throw new Error("No suitable React render method available");
299
+ }
300
+ target.dispatchEvent(
301
+ new CustomEvent("frontmcp:rendered", {
302
+ bubbles: true,
303
+ detail: { type: "react", toolName: context.toolName }
304
+ })
305
+ );
306
+ return { success: true };
307
+ } catch (error) {
308
+ const message = error instanceof Error ? error.message : String(error);
309
+ console.error("[FrontMCP] React render failed:", message);
310
+ return { success: false, error: message };
311
+ }
312
+ }
313
+ /**
314
+ * Hydrate existing SSR content with React.
315
+ */
316
+ async hydrate(target, context, options) {
317
+ return this.renderToDOM("", target, context, { ...options, hydrate: true });
318
+ }
319
+ /**
320
+ * Update rendered React component with new data.
321
+ */
322
+ async update(target, context) {
323
+ try {
324
+ await this.ensureReactLoaded();
325
+ if (!this.react) {
326
+ throw new Error("React runtime not available");
327
+ }
328
+ const existingRoot = mountedRoots.get(target);
329
+ const componentName = target.getAttribute("data-component");
330
+ const component = this.getComponent(componentName, "");
331
+ if (!component) {
332
+ return { success: false, error: "No component found for update" };
333
+ }
334
+ const element = this.react.createElement(component, {
335
+ input: context.input,
336
+ output: context.output,
337
+ structuredContent: context.structuredContent,
338
+ toolName: context.toolName
339
+ });
340
+ if (existingRoot && "render" in existingRoot) {
341
+ existingRoot.render(element);
342
+ return { success: true };
343
+ }
344
+ return this.renderToDOM("", target, context);
345
+ } catch (error) {
346
+ const message = error instanceof Error ? error.message : String(error);
347
+ console.error("[FrontMCP] React update failed:", message);
348
+ return { success: false, error: message };
349
+ }
350
+ }
351
+ /**
352
+ * Clean up React root.
353
+ */
354
+ destroy(target) {
355
+ const root = mountedRoots.get(target);
356
+ if (root) {
357
+ root.unmount();
358
+ mountedRoots.delete(target);
359
+ }
360
+ }
361
+ /**
362
+ * Ensure React is loaded.
363
+ */
364
+ async ensureReactLoaded() {
365
+ if (this.react && this.reactDOM) {
366
+ return;
367
+ }
368
+ if (this.loadPromise) {
369
+ return this.loadPromise;
370
+ }
371
+ this.loadPromise = this.loadReact();
372
+ return this.loadPromise;
373
+ }
374
+ /**
375
+ * Load React runtime.
1602
376
  */
1603
377
  async loadReact() {
1604
- if (this.React && this.ReactDOMServer) {
378
+ const win = typeof window !== "undefined" ? window : globalThis;
379
+ if (win.React) {
380
+ this.react = win.React;
381
+ }
382
+ if (win.ReactDOM) {
383
+ this.reactDOM = win.ReactDOM;
384
+ }
385
+ if (this.react && this.reactDOM) {
1605
386
  return;
1606
387
  }
1607
388
  try {
1608
- this.React = await import("react");
1609
- this.ReactDOMServer = await import("react-dom/server");
389
+ if (!this.react) {
390
+ const reactModule = await import(
391
+ /* webpackIgnore: true */
392
+ "react"
393
+ );
394
+ this.react = reactModule.default || reactModule;
395
+ }
396
+ if (!this.reactDOM) {
397
+ const reactDOMModule = await import(
398
+ /* webpackIgnore: true */
399
+ "react-dom/client"
400
+ );
401
+ this.reactDOM = reactDOMModule.default || reactDOMModule;
402
+ }
1610
403
  } catch {
1611
- throw new Error("React is required for ReactRenderer. Install react and react-dom: npm install react react-dom");
404
+ if (!this.react || !this.reactDOM) {
405
+ console.warn("[FrontMCP] React runtime not available. Ensure React is loaded via CDN or bundled.");
406
+ }
1612
407
  }
1613
408
  }
1614
- };
1615
- var reactRenderer = new ReactRenderer();
1616
- function buildHydrationScript() {
1617
- return `
1618
- <script>
1619
- (function() {
1620
- // Wait for React to be available
1621
- if (typeof React === 'undefined' || typeof ReactDOM === 'undefined') {
1622
- console.warn('[FrontMCP] React not available for hydration');
1623
- return;
1624
- }
1625
-
1626
- // Find all elements marked for hydration
1627
- document.querySelectorAll('[data-hydrate]').forEach(function(root) {
1628
- var componentName = root.getAttribute('data-hydrate');
1629
- var propsJson = root.getAttribute('data-props');
1630
- var props = propsJson ? JSON.parse(propsJson) : {};
1631
-
1632
- // Look for the component in the global scope
1633
- if (window.__frontmcp_components && window.__frontmcp_components[componentName]) {
1634
- try {
1635
- ReactDOM.hydrateRoot(root, React.createElement(
1636
- window.__frontmcp_components[componentName],
1637
- props
1638
- ));
1639
- } catch (e) {
1640
- console.error('[FrontMCP] Hydration failed for', componentName, e);
409
+ /**
410
+ * Get a React component by name or from content.
411
+ */
412
+ getComponent(componentName, content) {
413
+ const win = typeof window !== "undefined" ? window : globalThis;
414
+ if (componentName && win.__frontmcp_components) {
415
+ const registered = win.__frontmcp_components?.[componentName];
416
+ if (registered) {
417
+ return registered;
1641
418
  }
1642
419
  }
1643
- });
1644
- })();
1645
- </script>
1646
- `;
420
+ if (content && typeof content === "function") {
421
+ return content;
422
+ }
423
+ return null;
424
+ }
425
+ };
426
+ function createReactAdapter() {
427
+ return new ReactRendererAdapter();
428
+ }
429
+ async function loadReactAdapter() {
430
+ return createReactAdapter();
1647
431
  }
1648
432
 
1649
433
  // libs/ui/src/renderers/mdx.renderer.ts
1650
- var REACT_CDN2 = {
1651
- react: "https://unpkg.com/react@18/umd/react.production.min.js",
1652
- reactDom: "https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
1653
- };
434
+ var import_renderers2 = require("@frontmcp/uipack/renderers");
435
+ function buildReactCdnUrls(version = "19") {
436
+ return {
437
+ react: `https://esm.sh/react@${version}`,
438
+ reactDom: `https://esm.sh/react-dom@${version}/client`
439
+ };
440
+ }
441
+ var REACT_CDN2 = buildReactCdnUrls("19");
1654
442
  var INLINE_MDX_PLACEHOLDER = `
1655
443
  // MDX runtime not available inline yet.
1656
444
  // For blocked-network platforms, use pre-rendered HTML templates.
@@ -1680,28 +468,25 @@ var MdxRenderer = class {
1680
468
  if (typeof template !== "string") {
1681
469
  return false;
1682
470
  }
1683
- return containsMdxSyntax(template);
471
+ return (0, import_renderers2.containsMdxSyntax)(template);
1684
472
  }
1685
473
  /**
1686
- * Transpile MDX to executable JavaScript.
1687
- *
1688
- * Uses @mdx-js/mdx to compile MDX source to a module.
1689
- * Note: For MDX, we use evaluate() which combines compile + run,
1690
- * so this method just returns the source hash for caching purposes.
474
+ * Prepare MDX template for rendering.
475
+ * Caches the template hash for deduplication. Actual MDX compilation
476
+ * happens during render() via @mdx-js/mdx evaluate().
1691
477
  */
1692
478
  async transpile(template, _options) {
1693
- const hash = hashString(template);
1694
- const cached = transpileCache.getByKey(hash);
479
+ const hash = (0, import_renderers2.hashString)(template);
480
+ const cached = import_renderers2.transpileCache.getByKey(hash);
1695
481
  if (cached) {
1696
482
  return { ...cached, cached: true };
1697
483
  }
1698
484
  const transpileResult = {
1699
485
  code: template,
1700
- // Store original MDX for evaluate()
1701
486
  hash,
1702
487
  cached: false
1703
488
  };
1704
- transpileCache.setByKey(hash, transpileResult);
489
+ import_renderers2.transpileCache.setByKey(hash, transpileResult);
1705
490
  return transpileResult;
1706
491
  }
1707
492
  /**
@@ -1716,9 +501,9 @@ var MdxRenderer = class {
1716
501
  if (!this.mdxEvaluate) {
1717
502
  throw new Error("MDX compilation requires @mdx-js/mdx. Install it: npm install @mdx-js/mdx");
1718
503
  }
1719
- const templateHash = hashString(template);
504
+ const templateHash = (0, import_renderers2.hashString)(template);
1720
505
  const cacheKey = `mdx-component:${templateHash}`;
1721
- let Content = componentCache.get(cacheKey);
506
+ let Content = import_renderers2.componentCache.get(cacheKey);
1722
507
  if (!Content) {
1723
508
  const result = await this.mdxEvaluate(template, {
1724
509
  ...this.jsxRuntime,
@@ -1726,12 +511,10 @@ var MdxRenderer = class {
1726
511
  development: false
1727
512
  });
1728
513
  Content = result.default;
1729
- componentCache.set(cacheKey, Content);
514
+ import_renderers2.componentCache.set(cacheKey, Content);
1730
515
  }
1731
516
  const mdxComponents = {
1732
- // User-provided components from tool config
1733
517
  ...options?.mdxComponents,
1734
- // Wrapper that provides context to the content
1735
518
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1736
519
  wrapper: ({ children }) => {
1737
520
  return this.React.createElement("div", { className: "mdx-content" }, children);
@@ -1743,9 +526,11 @@ var MdxRenderer = class {
1743
526
  structuredContent: context.structuredContent,
1744
527
  helpers: context.helpers
1745
528
  };
529
+ const reservedProps = /* @__PURE__ */ new Set(["input", "output", "structuredContent", "helpers", "components"]);
530
+ const outputProps = typeof context.output === "object" && context.output !== null ? Object.fromEntries(Object.entries(context.output).filter(([key]) => !reservedProps.has(key))) : {};
1746
531
  const spreadProps = {
1747
- ...props,
1748
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
532
+ ...outputProps,
533
+ ...props
1749
534
  };
1750
535
  const element = this.React.createElement(Content, {
1751
536
  components: mdxComponents,
@@ -1799,10 +584,6 @@ var MdxRenderer = class {
1799
584
  }
1800
585
  /**
1801
586
  * Load @mdx-js/mdx evaluate function.
1802
- *
1803
- * evaluate() is the cleanest way to run MDX - it combines
1804
- * compile and run in a single step, handling all the runtime
1805
- * injection automatically.
1806
587
  */
1807
588
  async loadMdx() {
1808
589
  if (this.mdxEvaluate) {
@@ -1819,64 +600,57 @@ var MdxRenderer = class {
1819
600
  }
1820
601
  };
1821
602
  var mdxRenderer = new MdxRenderer();
1822
- function buildMdxHydrationScript() {
1823
- return `
1824
- <script>
1825
- (function() {
1826
- // MDX hydration requires React and component definitions
1827
- if (typeof React === 'undefined' || typeof ReactDOM === 'undefined') {
1828
- console.warn('[FrontMCP] React not available for MDX hydration');
1829
- return;
1830
- }
1831
-
1832
- // Find all elements marked for MDX hydration
1833
- document.querySelectorAll('[data-mdx-hydrate]').forEach(function(root) {
1834
- var propsJson = root.getAttribute('data-props');
1835
- var props = propsJson ? JSON.parse(propsJson) : {};
1836
603
 
1837
- // MDX content is pre-rendered, hydration mainly attaches event handlers
1838
- // For full interactivity, components need to be available client-side
1839
- if (window.__frontmcp_mdx_content) {
1840
- try {
1841
- ReactDOM.hydrateRoot(root, React.createElement(
1842
- window.__frontmcp_mdx_content,
1843
- props
1844
- ));
1845
- } catch (e) {
1846
- console.error('[FrontMCP] MDX hydration failed', e);
1847
- }
604
+ // libs/ui/src/renderers/transpiler.ts
605
+ var import_renderers3 = require("@frontmcp/uipack/renderers");
606
+ async function executeTranspiledCode(code, context = {}) {
607
+ let React;
608
+ let jsxRuntime;
609
+ try {
610
+ React = await import("react");
611
+ jsxRuntime = await import("react/jsx-runtime");
612
+ } catch {
613
+ throw new Error("React is required for JSX templates. Install react: npm install react react-dom");
614
+ }
615
+ const exports2 = {};
616
+ const module2 = { exports: exports2 };
617
+ const require2 = (id) => {
618
+ switch (id) {
619
+ case "react":
620
+ return React;
621
+ case "react/jsx-runtime":
622
+ return jsxRuntime;
623
+ case "react/jsx-dev-runtime":
624
+ return jsxRuntime;
625
+ default:
626
+ if (context[id]) {
627
+ return context[id];
628
+ }
629
+ throw new Error(`Module '${id}' not available in JSX template context`);
1848
630
  }
1849
- });
1850
- })();
1851
- </script>
1852
- `;
631
+ };
632
+ try {
633
+ const fn = new Function("exports", "require", "module", "__filename", "__dirname", "React", "context", code);
634
+ fn(exports2, require2, module2, "template.js", "/", React, context);
635
+ const exportKeys = Object.keys(module2.exports);
636
+ return module2.exports["default"] || (exportKeys.length > 0 ? module2.exports[exportKeys[0]] : null) || module2.exports;
637
+ } catch (error) {
638
+ throw new Error(`Failed to execute transpiled JSX: ${error instanceof Error ? error.message : String(error)}`);
639
+ }
640
+ }
641
+ async function transpileAndExecute(source, context = {}) {
642
+ const result = await (0, import_renderers3.transpileJsx)(source);
643
+ return executeTranspiledCode(result.code, context);
1853
644
  }
1854
645
  // Annotate the CommonJS export names for ESM import in node:
1855
646
  0 && (module.exports = {
1856
- HtmlRenderer,
1857
647
  MdxRenderer,
1858
648
  ReactRenderer,
1859
- RendererRegistry,
1860
- TranspileCache,
1861
- buildHydrationScript,
1862
- buildMdxHydrationScript,
1863
- containsJsx,
1864
- containsMdxSyntax,
1865
- detectTemplateType,
649
+ ReactRendererAdapter,
650
+ createReactAdapter,
1866
651
  executeTranspiledCode,
1867
- hashCombined,
1868
- hashString,
1869
- htmlRenderer,
1870
- isHash,
1871
- isPlainHtml,
1872
- isReactComponent,
1873
- isSwcAvailable,
1874
- isTemplateBuilderFunction,
652
+ loadReactAdapter,
1875
653
  mdxRenderer,
1876
654
  reactRenderer,
1877
- renderCache,
1878
- rendererRegistry,
1879
- transpileAndExecute,
1880
- transpileCache,
1881
- transpileJsx
655
+ transpileAndExecute
1882
656
  });