@frontmcp/ui 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/README.md +140 -362
  2. package/bridge/runtime/index.d.ts +2 -1
  3. package/bridge/runtime/index.d.ts.map +1 -1
  4. package/bundler/file-cache/component-builder.d.ts +1 -1
  5. package/bundler/file-cache/component-builder.d.ts.map +1 -1
  6. package/bundler/file-cache/hash-calculator.d.ts +1 -1
  7. package/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  8. package/bundler/file-cache/storage/filesystem.d.ts +1 -1
  9. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  10. package/bundler/file-cache/storage/interface.d.ts +1 -1
  11. package/bundler/file-cache/storage/interface.d.ts.map +1 -1
  12. package/bundler/file-cache/storage/redis.d.ts +1 -1
  13. package/bundler/file-cache/storage/redis.d.ts.map +1 -1
  14. package/bundler/index.js +10 -1057
  15. package/components/alert.schema.d.ts +6 -6
  16. package/components/avatar.schema.d.ts +9 -9
  17. package/components/badge.schema.d.ts +9 -9
  18. package/components/button.schema.d.ts +9 -9
  19. package/components/card.schema.d.ts +7 -7
  20. package/components/form.schema.d.ts +24 -24
  21. package/components/index.js +128 -198
  22. package/components/modal.schema.d.ts +8 -8
  23. package/components/table.schema.d.ts +6 -6
  24. package/esm/bridge/runtime/index.d.ts +2 -1
  25. package/esm/bridge/runtime/index.d.ts.map +1 -1
  26. package/esm/bundler/file-cache/component-builder.d.ts +1 -1
  27. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -1
  28. package/esm/bundler/file-cache/hash-calculator.d.ts +1 -1
  29. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -1
  30. package/esm/bundler/file-cache/storage/filesystem.d.ts +1 -1
  31. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -1
  32. package/esm/bundler/file-cache/storage/interface.d.ts +1 -1
  33. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -1
  34. package/esm/bundler/file-cache/storage/redis.d.ts +1 -1
  35. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -1
  36. package/esm/bundler/index.js +3 -1050
  37. package/esm/components/alert.schema.d.ts +6 -6
  38. package/esm/components/avatar.schema.d.ts +9 -9
  39. package/esm/components/badge.schema.d.ts +9 -9
  40. package/esm/components/button.schema.d.ts +9 -9
  41. package/esm/components/card.schema.d.ts +7 -7
  42. package/esm/components/form.schema.d.ts +24 -24
  43. package/esm/components/index.js +136 -196
  44. package/esm/components/modal.schema.d.ts +8 -8
  45. package/esm/components/table.schema.d.ts +6 -6
  46. package/esm/index.d.ts +23 -39
  47. package/esm/index.d.ts.map +1 -1
  48. package/esm/index.js +4256 -16441
  49. package/esm/layouts/base.d.ts +2 -2
  50. package/esm/layouts/base.d.ts.map +1 -1
  51. package/esm/layouts/index.js +33 -516
  52. package/esm/package.json +8 -26
  53. package/esm/pages/index.js +100 -627
  54. package/esm/react/Alert.d.ts +1 -2
  55. package/esm/react/Alert.d.ts.map +1 -1
  56. package/esm/react/Badge.d.ts +1 -2
  57. package/esm/react/Badge.d.ts.map +1 -1
  58. package/esm/react/Button.d.ts +1 -2
  59. package/esm/react/Button.d.ts.map +1 -1
  60. package/esm/react/Card.d.ts +1 -2
  61. package/esm/react/Card.d.ts.map +1 -1
  62. package/esm/react/hooks/context.d.ts +1 -1
  63. package/esm/react/hooks/context.d.ts.map +1 -1
  64. package/esm/react/index.d.ts +5 -6
  65. package/esm/react/index.d.ts.map +1 -1
  66. package/esm/react/index.js +2074 -322
  67. package/esm/react/types.d.ts +1 -2
  68. package/esm/react/types.d.ts.map +1 -1
  69. package/esm/renderers/index.d.ts +10 -25
  70. package/esm/renderers/index.d.ts.map +1 -1
  71. package/esm/renderers/index.js +171 -1617
  72. package/esm/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  73. package/esm/renderers/react.adapter.d.ts.map +1 -0
  74. package/esm/renderers/react.renderer.d.ts +3 -3
  75. package/esm/renderers/react.renderer.d.ts.map +1 -1
  76. package/esm/universal/index.js +1755 -0
  77. package/esm/web-components/index.js +232 -287
  78. package/esm/widgets/index.js +89 -147
  79. package/index.d.ts +23 -39
  80. package/index.d.ts.map +1 -1
  81. package/index.js +6123 -18539
  82. package/layouts/base.d.ts +2 -2
  83. package/layouts/base.d.ts.map +1 -1
  84. package/layouts/index.js +43 -536
  85. package/package.json +8 -26
  86. package/pages/index.js +111 -648
  87. package/react/Alert.d.ts +1 -2
  88. package/react/Alert.d.ts.map +1 -1
  89. package/react/Badge.d.ts +1 -2
  90. package/react/Badge.d.ts.map +1 -1
  91. package/react/Button.d.ts +1 -2
  92. package/react/Button.d.ts.map +1 -1
  93. package/react/Card.d.ts +1 -2
  94. package/react/Card.d.ts.map +1 -1
  95. package/react/hooks/context.d.ts +1 -1
  96. package/react/hooks/context.d.ts.map +1 -1
  97. package/react/index.d.ts +5 -6
  98. package/react/index.d.ts.map +1 -1
  99. package/react/index.js +2065 -335
  100. package/react/types.d.ts +1 -2
  101. package/react/types.d.ts.map +1 -1
  102. package/renderers/index.d.ts +10 -25
  103. package/renderers/index.d.ts.map +1 -1
  104. package/renderers/index.js +175 -1641
  105. package/{runtime/adapters → renderers}/react.adapter.d.ts +2 -2
  106. package/renderers/react.adapter.d.ts.map +1 -0
  107. package/renderers/react.renderer.d.ts +3 -3
  108. package/renderers/react.renderer.d.ts.map +1 -1
  109. package/universal/index.js +1841 -0
  110. package/web-components/index.js +224 -289
  111. package/widgets/index.js +80 -148
  112. package/adapters/index.d.ts +0 -13
  113. package/adapters/index.d.ts.map +0 -1
  114. package/adapters/index.js +0 -462
  115. package/adapters/platform-meta.d.ts +0 -166
  116. package/adapters/platform-meta.d.ts.map +0 -1
  117. package/adapters/response-builder.d.ts +0 -108
  118. package/adapters/response-builder.d.ts.map +0 -1
  119. package/adapters/serving-mode.d.ts +0 -107
  120. package/adapters/serving-mode.d.ts.map +0 -1
  121. package/base-template/bridge.d.ts +0 -90
  122. package/base-template/bridge.d.ts.map +0 -1
  123. package/base-template/default-base-template.d.ts +0 -92
  124. package/base-template/default-base-template.d.ts.map +0 -1
  125. package/base-template/index.d.ts +0 -15
  126. package/base-template/index.d.ts.map +0 -1
  127. package/base-template/index.js +0 -1398
  128. package/base-template/polyfills.d.ts +0 -31
  129. package/base-template/polyfills.d.ts.map +0 -1
  130. package/base-template/theme-styles.d.ts +0 -74
  131. package/base-template/theme-styles.d.ts.map +0 -1
  132. package/build/cdn-resources.d.ts +0 -243
  133. package/build/cdn-resources.d.ts.map +0 -1
  134. package/build/index.d.ts +0 -295
  135. package/build/index.d.ts.map +0 -1
  136. package/build/index.js +0 -7096
  137. package/build/widget-manifest.d.ts +0 -362
  138. package/build/widget-manifest.d.ts.map +0 -1
  139. package/dependency/cdn-registry.d.ts +0 -98
  140. package/dependency/cdn-registry.d.ts.map +0 -1
  141. package/dependency/import-map.d.ts +0 -186
  142. package/dependency/import-map.d.ts.map +0 -1
  143. package/dependency/import-parser.d.ts +0 -82
  144. package/dependency/import-parser.d.ts.map +0 -1
  145. package/dependency/index.d.ts +0 -17
  146. package/dependency/index.d.ts.map +0 -1
  147. package/dependency/resolver.d.ts +0 -164
  148. package/dependency/resolver.d.ts.map +0 -1
  149. package/dependency/schemas.d.ts +0 -486
  150. package/dependency/schemas.d.ts.map +0 -1
  151. package/dependency/template-loader.d.ts +0 -204
  152. package/dependency/template-loader.d.ts.map +0 -1
  153. package/dependency/template-processor.d.ts +0 -118
  154. package/dependency/template-processor.d.ts.map +0 -1
  155. package/dependency/types.d.ts +0 -739
  156. package/dependency/types.d.ts.map +0 -1
  157. package/esm/adapters/index.d.ts +0 -13
  158. package/esm/adapters/index.d.ts.map +0 -1
  159. package/esm/adapters/index.js +0 -427
  160. package/esm/adapters/platform-meta.d.ts +0 -166
  161. package/esm/adapters/platform-meta.d.ts.map +0 -1
  162. package/esm/adapters/response-builder.d.ts +0 -108
  163. package/esm/adapters/response-builder.d.ts.map +0 -1
  164. package/esm/adapters/serving-mode.d.ts +0 -107
  165. package/esm/adapters/serving-mode.d.ts.map +0 -1
  166. package/esm/base-template/bridge.d.ts +0 -90
  167. package/esm/base-template/bridge.d.ts.map +0 -1
  168. package/esm/base-template/default-base-template.d.ts +0 -92
  169. package/esm/base-template/default-base-template.d.ts.map +0 -1
  170. package/esm/base-template/index.d.ts +0 -15
  171. package/esm/base-template/index.d.ts.map +0 -1
  172. package/esm/base-template/index.js +0 -1364
  173. package/esm/base-template/polyfills.d.ts +0 -31
  174. package/esm/base-template/polyfills.d.ts.map +0 -1
  175. package/esm/base-template/theme-styles.d.ts +0 -74
  176. package/esm/base-template/theme-styles.d.ts.map +0 -1
  177. package/esm/build/cdn-resources.d.ts +0 -243
  178. package/esm/build/cdn-resources.d.ts.map +0 -1
  179. package/esm/build/index.d.ts +0 -295
  180. package/esm/build/index.d.ts.map +0 -1
  181. package/esm/build/index.js +0 -7021
  182. package/esm/build/widget-manifest.d.ts +0 -362
  183. package/esm/build/widget-manifest.d.ts.map +0 -1
  184. package/esm/dependency/cdn-registry.d.ts +0 -98
  185. package/esm/dependency/cdn-registry.d.ts.map +0 -1
  186. package/esm/dependency/import-map.d.ts +0 -186
  187. package/esm/dependency/import-map.d.ts.map +0 -1
  188. package/esm/dependency/import-parser.d.ts +0 -82
  189. package/esm/dependency/import-parser.d.ts.map +0 -1
  190. package/esm/dependency/index.d.ts +0 -17
  191. package/esm/dependency/index.d.ts.map +0 -1
  192. package/esm/dependency/resolver.d.ts +0 -164
  193. package/esm/dependency/resolver.d.ts.map +0 -1
  194. package/esm/dependency/schemas.d.ts +0 -486
  195. package/esm/dependency/schemas.d.ts.map +0 -1
  196. package/esm/dependency/template-loader.d.ts +0 -204
  197. package/esm/dependency/template-loader.d.ts.map +0 -1
  198. package/esm/dependency/template-processor.d.ts +0 -118
  199. package/esm/dependency/template-processor.d.ts.map +0 -1
  200. package/esm/dependency/types.d.ts +0 -739
  201. package/esm/dependency/types.d.ts.map +0 -1
  202. package/esm/handlebars/expression-extractor.d.ts +0 -147
  203. package/esm/handlebars/expression-extractor.d.ts.map +0 -1
  204. package/esm/handlebars/helpers.d.ts +0 -339
  205. package/esm/handlebars/helpers.d.ts.map +0 -1
  206. package/esm/handlebars/index.d.ts +0 -195
  207. package/esm/handlebars/index.d.ts.map +0 -1
  208. package/esm/handlebars/index.js +0 -587
  209. package/esm/registry/index.d.ts +0 -46
  210. package/esm/registry/index.d.ts.map +0 -1
  211. package/esm/registry/index.js +0 -6422
  212. package/esm/registry/render-template.d.ts +0 -91
  213. package/esm/registry/render-template.d.ts.map +0 -1
  214. package/esm/registry/tool-ui.registry.d.ts +0 -294
  215. package/esm/registry/tool-ui.registry.d.ts.map +0 -1
  216. package/esm/registry/uri-utils.d.ts +0 -56
  217. package/esm/registry/uri-utils.d.ts.map +0 -1
  218. package/esm/renderers/cache.d.ts +0 -145
  219. package/esm/renderers/cache.d.ts.map +0 -1
  220. package/esm/renderers/html.renderer.d.ts +0 -123
  221. package/esm/renderers/html.renderer.d.ts.map +0 -1
  222. package/esm/renderers/mdx.renderer.d.ts +0 -120
  223. package/esm/renderers/mdx.renderer.d.ts.map +0 -1
  224. package/esm/renderers/registry.d.ts +0 -134
  225. package/esm/renderers/registry.d.ts.map +0 -1
  226. package/esm/renderers/types.d.ts +0 -342
  227. package/esm/renderers/types.d.ts.map +0 -1
  228. package/esm/renderers/utils/detect.d.ts +0 -107
  229. package/esm/renderers/utils/detect.d.ts.map +0 -1
  230. package/esm/renderers/utils/hash.d.ts +0 -40
  231. package/esm/renderers/utils/hash.d.ts.map +0 -1
  232. package/esm/renderers/utils/index.d.ts +0 -9
  233. package/esm/renderers/utils/index.d.ts.map +0 -1
  234. package/esm/renderers/utils/transpiler.d.ts +0 -89
  235. package/esm/renderers/utils/transpiler.d.ts.map +0 -1
  236. package/esm/runtime/adapters/html.adapter.d.ts +0 -59
  237. package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
  238. package/esm/runtime/adapters/index.d.ts +0 -26
  239. package/esm/runtime/adapters/index.d.ts.map +0 -1
  240. package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
  241. package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  242. package/esm/runtime/adapters/react.adapter.d.ts.map +0 -1
  243. package/esm/runtime/adapters/types.d.ts +0 -95
  244. package/esm/runtime/adapters/types.d.ts.map +0 -1
  245. package/esm/runtime/csp.d.ts +0 -48
  246. package/esm/runtime/csp.d.ts.map +0 -1
  247. package/esm/runtime/index.d.ts +0 -17
  248. package/esm/runtime/index.d.ts.map +0 -1
  249. package/esm/runtime/index.js +0 -5186
  250. package/esm/runtime/mcp-bridge.d.ts +0 -101
  251. package/esm/runtime/mcp-bridge.d.ts.map +0 -1
  252. package/esm/runtime/renderer-runtime.d.ts +0 -133
  253. package/esm/runtime/renderer-runtime.d.ts.map +0 -1
  254. package/esm/runtime/sanitizer.d.ts +0 -172
  255. package/esm/runtime/sanitizer.d.ts.map +0 -1
  256. package/esm/runtime/types.d.ts +0 -415
  257. package/esm/runtime/types.d.ts.map +0 -1
  258. package/esm/runtime/wrapper.d.ts +0 -421
  259. package/esm/runtime/wrapper.d.ts.map +0 -1
  260. package/esm/styles/index.d.ts +0 -8
  261. package/esm/styles/index.d.ts.map +0 -1
  262. package/esm/styles/index.js +0 -171
  263. package/esm/styles/variants.d.ts +0 -51
  264. package/esm/styles/variants.d.ts.map +0 -1
  265. package/esm/theme/cdn.d.ts +0 -195
  266. package/esm/theme/cdn.d.ts.map +0 -1
  267. package/esm/theme/index.d.ts +0 -18
  268. package/esm/theme/index.d.ts.map +0 -1
  269. package/esm/theme/index.js +0 -700
  270. package/esm/theme/platforms.d.ts +0 -107
  271. package/esm/theme/platforms.d.ts.map +0 -1
  272. package/esm/theme/presets/github-openai.d.ts +0 -50
  273. package/esm/theme/presets/github-openai.d.ts.map +0 -1
  274. package/esm/theme/presets/index.d.ts +0 -11
  275. package/esm/theme/presets/index.d.ts.map +0 -1
  276. package/esm/theme/theme.d.ts +0 -396
  277. package/esm/theme/theme.d.ts.map +0 -1
  278. package/esm/tool-template/builder.d.ts +0 -213
  279. package/esm/tool-template/builder.d.ts.map +0 -1
  280. package/esm/tool-template/index.d.ts +0 -16
  281. package/esm/tool-template/index.d.ts.map +0 -1
  282. package/esm/tool-template/index.js +0 -3515
  283. package/esm/types/index.d.ts +0 -14
  284. package/esm/types/index.d.ts.map +0 -1
  285. package/esm/types/index.js +0 -75
  286. package/esm/types/ui-config.d.ts +0 -639
  287. package/esm/types/ui-config.d.ts.map +0 -1
  288. package/esm/types/ui-runtime.d.ts +0 -1007
  289. package/esm/types/ui-runtime.d.ts.map +0 -1
  290. package/esm/typings/cache/cache-adapter.d.ts +0 -125
  291. package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
  292. package/esm/typings/cache/index.d.ts +0 -10
  293. package/esm/typings/cache/index.d.ts.map +0 -1
  294. package/esm/typings/cache/memory-cache.d.ts +0 -92
  295. package/esm/typings/cache/memory-cache.d.ts.map +0 -1
  296. package/esm/typings/dts-parser.d.ts +0 -90
  297. package/esm/typings/dts-parser.d.ts.map +0 -1
  298. package/esm/typings/index.d.ts +0 -48
  299. package/esm/typings/index.d.ts.map +0 -1
  300. package/esm/typings/schemas.d.ts +0 -232
  301. package/esm/typings/schemas.d.ts.map +0 -1
  302. package/esm/typings/type-fetcher.d.ts +0 -89
  303. package/esm/typings/type-fetcher.d.ts.map +0 -1
  304. package/esm/typings/types.d.ts +0 -320
  305. package/esm/typings/types.d.ts.map +0 -1
  306. package/esm/utils/escape-html.d.ts +0 -58
  307. package/esm/utils/escape-html.d.ts.map +0 -1
  308. package/esm/utils/index.d.ts +0 -10
  309. package/esm/utils/index.d.ts.map +0 -1
  310. package/esm/utils/index.js +0 -40
  311. package/esm/utils/safe-stringify.d.ts +0 -30
  312. package/esm/utils/safe-stringify.d.ts.map +0 -1
  313. package/esm/validation/error-box.d.ts +0 -56
  314. package/esm/validation/error-box.d.ts.map +0 -1
  315. package/esm/validation/index.d.ts +0 -13
  316. package/esm/validation/index.d.ts.map +0 -1
  317. package/esm/validation/index.js +0 -562
  318. package/esm/validation/schema-paths.d.ts +0 -118
  319. package/esm/validation/schema-paths.d.ts.map +0 -1
  320. package/esm/validation/template-validator.d.ts +0 -143
  321. package/esm/validation/template-validator.d.ts.map +0 -1
  322. package/esm/validation/wrapper.d.ts +0 -97
  323. package/esm/validation/wrapper.d.ts.map +0 -1
  324. package/handlebars/expression-extractor.d.ts +0 -147
  325. package/handlebars/expression-extractor.d.ts.map +0 -1
  326. package/handlebars/helpers.d.ts +0 -339
  327. package/handlebars/helpers.d.ts.map +0 -1
  328. package/handlebars/index.d.ts +0 -195
  329. package/handlebars/index.d.ts.map +0 -1
  330. package/handlebars/index.js +0 -666
  331. package/registry/index.d.ts +0 -46
  332. package/registry/index.d.ts.map +0 -1
  333. package/registry/index.js +0 -6465
  334. package/registry/render-template.d.ts +0 -91
  335. package/registry/render-template.d.ts.map +0 -1
  336. package/registry/tool-ui.registry.d.ts +0 -294
  337. package/registry/tool-ui.registry.d.ts.map +0 -1
  338. package/registry/uri-utils.d.ts +0 -56
  339. package/registry/uri-utils.d.ts.map +0 -1
  340. package/renderers/cache.d.ts +0 -145
  341. package/renderers/cache.d.ts.map +0 -1
  342. package/renderers/html.renderer.d.ts +0 -123
  343. package/renderers/html.renderer.d.ts.map +0 -1
  344. package/renderers/mdx.renderer.d.ts +0 -120
  345. package/renderers/mdx.renderer.d.ts.map +0 -1
  346. package/renderers/registry.d.ts +0 -134
  347. package/renderers/registry.d.ts.map +0 -1
  348. package/renderers/types.d.ts +0 -342
  349. package/renderers/types.d.ts.map +0 -1
  350. package/renderers/utils/detect.d.ts +0 -107
  351. package/renderers/utils/detect.d.ts.map +0 -1
  352. package/renderers/utils/hash.d.ts +0 -40
  353. package/renderers/utils/hash.d.ts.map +0 -1
  354. package/renderers/utils/index.d.ts +0 -9
  355. package/renderers/utils/index.d.ts.map +0 -1
  356. package/renderers/utils/transpiler.d.ts +0 -89
  357. package/renderers/utils/transpiler.d.ts.map +0 -1
  358. package/runtime/adapters/html.adapter.d.ts +0 -59
  359. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  360. package/runtime/adapters/index.d.ts +0 -26
  361. package/runtime/adapters/index.d.ts.map +0 -1
  362. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  363. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  364. package/runtime/adapters/react.adapter.d.ts.map +0 -1
  365. package/runtime/adapters/types.d.ts +0 -95
  366. package/runtime/adapters/types.d.ts.map +0 -1
  367. package/runtime/csp.d.ts +0 -48
  368. package/runtime/csp.d.ts.map +0 -1
  369. package/runtime/index.d.ts +0 -17
  370. package/runtime/index.d.ts.map +0 -1
  371. package/runtime/index.js +0 -5264
  372. package/runtime/mcp-bridge.d.ts +0 -101
  373. package/runtime/mcp-bridge.d.ts.map +0 -1
  374. package/runtime/renderer-runtime.d.ts +0 -133
  375. package/runtime/renderer-runtime.d.ts.map +0 -1
  376. package/runtime/sanitizer.d.ts +0 -172
  377. package/runtime/sanitizer.d.ts.map +0 -1
  378. package/runtime/types.d.ts +0 -415
  379. package/runtime/types.d.ts.map +0 -1
  380. package/runtime/wrapper.d.ts +0 -421
  381. package/runtime/wrapper.d.ts.map +0 -1
  382. package/styles/index.d.ts +0 -8
  383. package/styles/index.d.ts.map +0 -1
  384. package/styles/index.js +0 -222
  385. package/styles/variants.d.ts +0 -51
  386. package/styles/variants.d.ts.map +0 -1
  387. package/theme/cdn.d.ts +0 -195
  388. package/theme/cdn.d.ts.map +0 -1
  389. package/theme/index.d.ts +0 -18
  390. package/theme/index.d.ts.map +0 -1
  391. package/theme/index.js +0 -757
  392. package/theme/platforms.d.ts +0 -107
  393. package/theme/platforms.d.ts.map +0 -1
  394. package/theme/presets/github-openai.d.ts +0 -50
  395. package/theme/presets/github-openai.d.ts.map +0 -1
  396. package/theme/presets/index.d.ts +0 -11
  397. package/theme/presets/index.d.ts.map +0 -1
  398. package/theme/theme.d.ts +0 -396
  399. package/theme/theme.d.ts.map +0 -1
  400. package/tool-template/builder.d.ts +0 -213
  401. package/tool-template/builder.d.ts.map +0 -1
  402. package/tool-template/index.d.ts +0 -16
  403. package/tool-template/index.d.ts.map +0 -1
  404. package/tool-template/index.js +0 -3559
  405. package/types/index.d.ts +0 -14
  406. package/types/index.d.ts.map +0 -1
  407. package/types/index.js +0 -108
  408. package/types/ui-config.d.ts +0 -639
  409. package/types/ui-config.d.ts.map +0 -1
  410. package/types/ui-runtime.d.ts +0 -1007
  411. package/types/ui-runtime.d.ts.map +0 -1
  412. package/typings/cache/cache-adapter.d.ts +0 -125
  413. package/typings/cache/cache-adapter.d.ts.map +0 -1
  414. package/typings/cache/index.d.ts +0 -10
  415. package/typings/cache/index.d.ts.map +0 -1
  416. package/typings/cache/memory-cache.d.ts +0 -92
  417. package/typings/cache/memory-cache.d.ts.map +0 -1
  418. package/typings/dts-parser.d.ts +0 -90
  419. package/typings/dts-parser.d.ts.map +0 -1
  420. package/typings/index.d.ts +0 -48
  421. package/typings/index.d.ts.map +0 -1
  422. package/typings/schemas.d.ts +0 -232
  423. package/typings/schemas.d.ts.map +0 -1
  424. package/typings/type-fetcher.d.ts +0 -89
  425. package/typings/type-fetcher.d.ts.map +0 -1
  426. package/typings/types.d.ts +0 -320
  427. package/typings/types.d.ts.map +0 -1
  428. package/utils/escape-html.d.ts +0 -58
  429. package/utils/escape-html.d.ts.map +0 -1
  430. package/utils/index.d.ts +0 -10
  431. package/utils/index.d.ts.map +0 -1
  432. package/utils/index.js +0 -70
  433. package/utils/safe-stringify.d.ts +0 -30
  434. package/utils/safe-stringify.d.ts.map +0 -1
  435. package/validation/error-box.d.ts +0 -56
  436. package/validation/error-box.d.ts.map +0 -1
  437. package/validation/index.d.ts +0 -13
  438. package/validation/index.d.ts.map +0 -1
  439. package/validation/index.js +0 -603
  440. package/validation/schema-paths.d.ts +0 -118
  441. package/validation/schema-paths.d.ts.map +0 -1
  442. package/validation/template-validator.d.ts +0 -143
  443. package/validation/template-validator.d.ts.map +0 -1
  444. package/validation/wrapper.d.ts +0 -97
  445. package/validation/wrapper.d.ts.map +0 -1
@@ -5,9 +5,6 @@ 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
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,1453 +27,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
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
30
  // libs/ui/src/renderers/index.ts
666
31
  var renderers_exports = {};
667
32
  __export(renderers_exports, {
668
- HtmlRenderer: () => HtmlRenderer,
669
- MdxRenderer: () => MdxRenderer,
670
33
  ReactRenderer: () => ReactRenderer,
671
- RendererRegistry: () => RendererRegistry,
672
- TranspileCache: () => TranspileCache,
34
+ ReactRendererAdapter: () => ReactRendererAdapter,
673
35
  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
36
+ createReactAdapter: () => createReactAdapter,
37
+ loadReactAdapter: () => loadReactAdapter,
38
+ reactRenderer: () => reactRenderer
694
39
  });
695
40
  module.exports = __toCommonJS(renderers_exports);
696
41
 
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
- };
1368
- }
1369
- };
1370
- var rendererRegistry = new RendererRegistry();
1371
-
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;
1439
- }
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)}`);
1472
- }
1473
- }
1474
- async function transpileAndExecute(source, context = {}) {
1475
- const result = await transpileJsx(source);
1476
- return executeTranspiledCode(result.code, context);
1477
- }
1478
-
1479
42
  // libs/ui/src/renderers/react.renderer.ts
43
+ var import_renderers = require("@frontmcp/uipack/renderers");
1480
44
  var REACT_CDN = {
1481
45
  react: "https://esm.sh/react@19",
1482
46
  reactDom: "https://esm.sh/react-dom@19/client"
@@ -1505,10 +69,10 @@ var ReactRenderer = class {
1505
69
  * - Strings containing JSX syntax
1506
70
  */
1507
71
  canHandle(template) {
1508
- if (typeof template === "function" && isReactComponent(template)) {
72
+ if (typeof template === "function" && (0, import_renderers.isReactComponent)(template)) {
1509
73
  return true;
1510
74
  }
1511
- if (typeof template === "string" && containsJsx(template)) {
75
+ if (typeof template === "string" && (0, import_renderers.containsJsx)(template)) {
1512
76
  return true;
1513
77
  }
1514
78
  return false;
@@ -1521,7 +85,7 @@ var ReactRenderer = class {
1521
85
  */
1522
86
  async transpile(template, options) {
1523
87
  if (typeof template === "function") {
1524
- const hash = hashString(template.toString());
88
+ const hash = (0, import_renderers.hashString)(template.toString());
1525
89
  return {
1526
90
  code: "",
1527
91
  // No transpiled code for already-compiled components
@@ -1530,7 +94,7 @@ var ReactRenderer = class {
1530
94
  };
1531
95
  }
1532
96
  if (typeof template === "string") {
1533
- return transpileJsx(template, {
97
+ return (0, import_renderers.transpileJsx)(template, {
1534
98
  development: options?.sourceMaps ?? false
1535
99
  });
1536
100
  }
@@ -1546,15 +110,15 @@ var ReactRenderer = class {
1546
110
  Component = template;
1547
111
  } else if (typeof template === "string") {
1548
112
  const transpiled = await this.transpile(template);
1549
- const cached = transpileCache.getByKey(`exec:${transpiled.hash}`);
113
+ const cached = import_renderers.transpileCache.getByKey(`exec:${transpiled.hash}`);
1550
114
  if (cached) {
1551
115
  Component = cached.code;
1552
116
  } else {
1553
- Component = await executeTranspiledCode(transpiled.code, {
117
+ Component = await (0, import_renderers.executeTranspiledCode)(transpiled.code, {
1554
118
  // Provide any additional MDX components if specified
1555
119
  ...options?.mdxComponents
1556
120
  });
1557
- transpileCache.setByKey(`exec:${transpiled.hash}`, {
121
+ import_renderers.transpileCache.setByKey(`exec:${transpiled.hash}`, {
1558
122
  code: Component,
1559
123
  hash: transpiled.hash,
1560
124
  cached: false
@@ -1646,237 +210,207 @@ function buildHydrationScript() {
1646
210
  `;
1647
211
  }
1648
212
 
1649
- // 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
- };
1654
- var INLINE_MDX_PLACEHOLDER = `
1655
- // MDX runtime not available inline yet.
1656
- // For blocked-network platforms, use pre-rendered HTML templates.
1657
- console.warn('[FrontMCP] MDX hydration not available on this platform.');
1658
- `;
1659
- var MdxRenderer = class {
1660
- type = "mdx";
1661
- priority = 10;
1662
- // Between HTML (0) and React (20)
213
+ // libs/ui/src/renderers/react.adapter.ts
214
+ var mountedRoots = /* @__PURE__ */ new WeakMap();
215
+ var ReactRendererAdapter = class {
216
+ type = "react";
217
+ // Lazy-loaded React runtime
218
+ react = null;
219
+ reactDOM = null;
220
+ loadPromise = null;
1663
221
  /**
1664
- * Lazy-loaded modules.
222
+ * Check if this adapter can handle the given content.
1665
223
  */
1666
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1667
- React = null;
1668
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1669
- ReactDOMServer = null;
1670
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1671
- jsxRuntime = null;
1672
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1673
- mdxEvaluate = null;
224
+ canHandle(content) {
225
+ if (typeof content === "function") {
226
+ return true;
227
+ }
228
+ if (typeof content === "string") {
229
+ return content.includes("React.createElement") || content.includes("jsx(") || content.includes("jsxs(") || /function\s+\w+\s*\([^)]*\)\s*\{[\s\S]*return\s*[\s\S]*</.test(content);
230
+ }
231
+ return false;
232
+ }
1674
233
  /**
1675
- * Check if this renderer can handle the given template.
1676
- *
1677
- * Accepts strings containing MDX syntax (Markdown + JSX).
234
+ * Render React component to a string.
235
+ * This is a client-side fallback - SSR should be done at build time.
1678
236
  */
1679
- canHandle(template) {
1680
- if (typeof template !== "string") {
1681
- return false;
1682
- }
1683
- return containsMdxSyntax(template);
237
+ async render(content, context, _options) {
238
+ return `<div data-frontmcp-react data-tool="${context.toolName}">${content}</div>`;
1684
239
  }
1685
240
  /**
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.
241
+ * Render React component directly to the DOM.
1691
242
  */
1692
- async transpile(template, _options) {
1693
- const hash = hashString(template);
1694
- const cached = transpileCache.getByKey(hash);
1695
- if (cached) {
1696
- return { ...cached, cached: true };
243
+ async renderToDOM(content, target, context, options) {
244
+ try {
245
+ await this.ensureReactLoaded();
246
+ if (!this.react || !this.reactDOM) {
247
+ throw new Error("React runtime not available");
248
+ }
249
+ const componentName = target.getAttribute("data-component");
250
+ const component = this.getComponent(componentName, content);
251
+ if (!component) {
252
+ target.innerHTML = content;
253
+ return { success: true };
254
+ }
255
+ const element = this.react.createElement(component, {
256
+ input: context.input,
257
+ output: context.output,
258
+ structuredContent: context.structuredContent,
259
+ toolName: context.toolName
260
+ });
261
+ if (options?.hydrate && this.reactDOM.hydrateRoot) {
262
+ const root = this.reactDOM.hydrateRoot(target, element);
263
+ mountedRoots.set(target, root);
264
+ } else if (this.reactDOM.createRoot) {
265
+ const root = this.reactDOM.createRoot(target);
266
+ root.render(element);
267
+ mountedRoots.set(target, root);
268
+ } else if (this.reactDOM.render) {
269
+ this.reactDOM.render(element, target);
270
+ mountedRoots.set(target, {
271
+ unmount: () => this.reactDOM?.unmountComponentAtNode?.(target)
272
+ });
273
+ } else {
274
+ throw new Error("No suitable React render method available");
275
+ }
276
+ target.dispatchEvent(
277
+ new CustomEvent("frontmcp:rendered", {
278
+ bubbles: true,
279
+ detail: { type: "react", toolName: context.toolName }
280
+ })
281
+ );
282
+ return { success: true };
283
+ } catch (error) {
284
+ const message = error instanceof Error ? error.message : String(error);
285
+ console.error("[FrontMCP] React render failed:", message);
286
+ return { success: false, error: message };
1697
287
  }
1698
- const transpileResult = {
1699
- code: template,
1700
- // Store original MDX for evaluate()
1701
- hash,
1702
- cached: false
1703
- };
1704
- transpileCache.setByKey(hash, transpileResult);
1705
- return transpileResult;
1706
288
  }
1707
289
  /**
1708
- * Render MDX template to HTML string.
1709
- *
1710
- * Uses @mdx-js/mdx's evaluate() for clean compilation + execution,
1711
- * then renders the resulting React component to HTML via SSR.
290
+ * Hydrate existing SSR content with React.
1712
291
  */
1713
- async render(template, context, options) {
1714
- await this.loadReact();
1715
- await this.loadMdx();
1716
- if (!this.mdxEvaluate) {
1717
- throw new Error("MDX compilation requires @mdx-js/mdx. Install it: npm install @mdx-js/mdx");
1718
- }
1719
- const templateHash = hashString(template);
1720
- const cacheKey = `mdx-component:${templateHash}`;
1721
- let Content = componentCache.get(cacheKey);
1722
- if (!Content) {
1723
- const result = await this.mdxEvaluate(template, {
1724
- ...this.jsxRuntime,
1725
- Fragment: this.React.Fragment,
1726
- development: false
292
+ async hydrate(target, context, options) {
293
+ return this.renderToDOM("", target, context, { ...options, hydrate: true });
294
+ }
295
+ /**
296
+ * Update rendered React component with new data.
297
+ */
298
+ async update(target, context) {
299
+ try {
300
+ await this.ensureReactLoaded();
301
+ if (!this.react) {
302
+ throw new Error("React runtime not available");
303
+ }
304
+ const existingRoot = mountedRoots.get(target);
305
+ const componentName = target.getAttribute("data-component");
306
+ const component = this.getComponent(componentName, "");
307
+ if (!component) {
308
+ return { success: false, error: "No component found for update" };
309
+ }
310
+ const element = this.react.createElement(component, {
311
+ input: context.input,
312
+ output: context.output,
313
+ structuredContent: context.structuredContent,
314
+ toolName: context.toolName
1727
315
  });
1728
- Content = result.default;
1729
- componentCache.set(cacheKey, Content);
1730
- }
1731
- const mdxComponents = {
1732
- // User-provided components from tool config
1733
- ...options?.mdxComponents,
1734
- // Wrapper that provides context to the content
1735
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1736
- wrapper: ({ children }) => {
1737
- return this.React.createElement("div", { className: "mdx-content" }, children);
316
+ if (existingRoot && "render" in existingRoot) {
317
+ existingRoot.render(element);
318
+ return { success: true };
1738
319
  }
1739
- };
1740
- const props = {
1741
- input: context.input,
1742
- output: context.output,
1743
- structuredContent: context.structuredContent,
1744
- helpers: context.helpers
1745
- };
1746
- const spreadProps = {
1747
- ...props,
1748
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
1749
- };
1750
- const element = this.React.createElement(Content, {
1751
- components: mdxComponents,
1752
- ...spreadProps
1753
- });
1754
- const html = this.ReactDOMServer.renderToString(element);
1755
- if (options?.hydrate) {
1756
- const escapedProps = JSON.stringify(props).replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1757
- return `<div data-mdx-hydrate="true" data-props='${escapedProps}'>${html}</div>`;
320
+ return this.renderToDOM("", target, context);
321
+ } catch (error) {
322
+ const message = error instanceof Error ? error.message : String(error);
323
+ console.error("[FrontMCP] React update failed:", message);
324
+ return { success: false, error: message };
1758
325
  }
1759
- return html;
1760
326
  }
1761
327
  /**
1762
- * Get runtime scripts for client-side functionality.
328
+ * Clean up React root.
1763
329
  */
1764
- getRuntimeScripts(platform) {
1765
- if (platform.networkMode === "blocked") {
1766
- return {
1767
- headScripts: "",
1768
- inlineScripts: INLINE_MDX_PLACEHOLDER,
1769
- isInline: true
1770
- };
330
+ destroy(target) {
331
+ const root = mountedRoots.get(target);
332
+ if (root) {
333
+ root.unmount();
334
+ mountedRoots.delete(target);
1771
335
  }
1772
- return {
1773
- headScripts: `
1774
- <script crossorigin src="${REACT_CDN2.react}"></script>
1775
- <script crossorigin src="${REACT_CDN2.reactDom}"></script>
1776
- `,
1777
- isInline: false
1778
- };
1779
336
  }
1780
337
  /**
1781
- * Load React and ReactDOMServer modules.
338
+ * Ensure React is loaded.
1782
339
  */
1783
- async loadReact() {
1784
- if (this.React && this.ReactDOMServer && this.jsxRuntime) {
340
+ async ensureReactLoaded() {
341
+ if (this.react && this.reactDOM) {
1785
342
  return;
1786
343
  }
1787
- try {
1788
- const [react, reactDomServer, jsxRuntime] = await Promise.all([
1789
- import("react"),
1790
- import("react-dom/server"),
1791
- import("react/jsx-runtime")
1792
- ]);
1793
- this.React = react;
1794
- this.ReactDOMServer = reactDomServer;
1795
- this.jsxRuntime = jsxRuntime;
1796
- } catch {
1797
- throw new Error("React is required for MdxRenderer. Install react and react-dom: npm install react react-dom");
344
+ if (this.loadPromise) {
345
+ return this.loadPromise;
1798
346
  }
347
+ this.loadPromise = this.loadReact();
348
+ return this.loadPromise;
1799
349
  }
1800
350
  /**
1801
- * 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.
351
+ * Load React runtime.
1806
352
  */
1807
- async loadMdx() {
1808
- if (this.mdxEvaluate) {
353
+ async loadReact() {
354
+ const win = typeof window !== "undefined" ? window : globalThis;
355
+ if (win.React) {
356
+ this.react = win.React;
357
+ }
358
+ if (win.ReactDOM) {
359
+ this.reactDOM = win.ReactDOM;
360
+ }
361
+ if (this.react && this.reactDOM) {
1809
362
  return;
1810
363
  }
1811
364
  try {
1812
- const mdx = await import("@mdx-js/mdx");
1813
- this.mdxEvaluate = mdx.evaluate;
365
+ if (!this.react) {
366
+ const reactModule = await import(
367
+ /* webpackIgnore: true */
368
+ "react"
369
+ );
370
+ this.react = reactModule.default || reactModule;
371
+ }
372
+ if (!this.reactDOM) {
373
+ const reactDOMModule = await import(
374
+ /* webpackIgnore: true */
375
+ "react-dom/client"
376
+ );
377
+ this.reactDOM = reactDOMModule.default || reactDOMModule;
378
+ }
1814
379
  } catch {
1815
- console.warn(
1816
- "[@frontmcp/ui] @mdx-js/mdx not available. MDX rendering disabled. Install @mdx-js/mdx to enable: npm install @mdx-js/mdx"
1817
- );
380
+ if (!this.react || !this.reactDOM) {
381
+ console.warn("[FrontMCP] React runtime not available. Ensure React is loaded via CDN or bundled.");
382
+ }
1818
383
  }
1819
384
  }
1820
- };
1821
- 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
-
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);
385
+ /**
386
+ * Get a React component by name or from content.
387
+ */
388
+ getComponent(componentName, content) {
389
+ const win = typeof window !== "undefined" ? window : globalThis;
390
+ if (componentName && win.__frontmcp_components) {
391
+ const registered = win.__frontmcp_components?.[componentName];
392
+ if (registered) {
393
+ return registered;
1847
394
  }
1848
395
  }
1849
- });
1850
- })();
1851
- </script>
1852
- `;
396
+ if (content && typeof content === "function") {
397
+ return content;
398
+ }
399
+ return null;
400
+ }
401
+ };
402
+ function createReactAdapter() {
403
+ return new ReactRendererAdapter();
404
+ }
405
+ async function loadReactAdapter() {
406
+ return createReactAdapter();
1853
407
  }
1854
408
  // Annotate the CommonJS export names for ESM import in node:
1855
409
  0 && (module.exports = {
1856
- HtmlRenderer,
1857
- MdxRenderer,
1858
410
  ReactRenderer,
1859
- RendererRegistry,
1860
- TranspileCache,
411
+ ReactRendererAdapter,
1861
412
  buildHydrationScript,
1862
- buildMdxHydrationScript,
1863
- containsJsx,
1864
- containsMdxSyntax,
1865
- detectTemplateType,
1866
- executeTranspiledCode,
1867
- hashCombined,
1868
- hashString,
1869
- htmlRenderer,
1870
- isHash,
1871
- isPlainHtml,
1872
- isReactComponent,
1873
- isSwcAvailable,
1874
- isTemplateBuilderFunction,
1875
- mdxRenderer,
1876
- reactRenderer,
1877
- renderCache,
1878
- rendererRegistry,
1879
- transpileAndExecute,
1880
- transpileCache,
1881
- transpileJsx
413
+ createReactAdapter,
414
+ loadReactAdapter,
415
+ reactRenderer
1882
416
  });