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