@frontmcp/ui 0.5.0 → 0.6.0

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 (1134) hide show
  1. package/adapters/index.d.ts +13 -0
  2. package/adapters/index.d.ts.map +1 -0
  3. package/adapters/index.js +462 -0
  4. package/adapters/platform-meta.d.ts +166 -0
  5. package/adapters/platform-meta.d.ts.map +1 -0
  6. package/adapters/response-builder.d.ts +108 -0
  7. package/adapters/response-builder.d.ts.map +1 -0
  8. package/adapters/serving-mode.d.ts +107 -0
  9. package/adapters/serving-mode.d.ts.map +1 -0
  10. package/base-template/bridge.d.ts +90 -0
  11. package/base-template/bridge.d.ts.map +1 -0
  12. package/base-template/default-base-template.d.ts +92 -0
  13. package/base-template/default-base-template.d.ts.map +1 -0
  14. package/base-template/index.d.ts +15 -0
  15. package/base-template/index.d.ts.map +1 -0
  16. package/base-template/index.js +1398 -0
  17. package/base-template/polyfills.d.ts +31 -0
  18. package/base-template/polyfills.d.ts.map +1 -0
  19. package/base-template/theme-styles.d.ts +74 -0
  20. package/base-template/theme-styles.d.ts.map +1 -0
  21. package/bridge/adapters/base-adapter.d.ts +104 -0
  22. package/bridge/adapters/base-adapter.d.ts.map +1 -0
  23. package/bridge/adapters/claude.adapter.d.ts +67 -0
  24. package/bridge/adapters/claude.adapter.d.ts.map +1 -0
  25. package/bridge/adapters/ext-apps.adapter.d.ts +143 -0
  26. package/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
  27. package/bridge/adapters/gemini.adapter.d.ts +64 -0
  28. package/bridge/adapters/gemini.adapter.d.ts.map +1 -0
  29. package/bridge/adapters/generic.adapter.d.ts +56 -0
  30. package/bridge/adapters/generic.adapter.d.ts.map +1 -0
  31. package/bridge/adapters/index.d.ts +26 -0
  32. package/bridge/adapters/index.d.ts.map +1 -0
  33. package/bridge/adapters/openai.adapter.d.ts +65 -0
  34. package/bridge/adapters/openai.adapter.d.ts.map +1 -0
  35. package/bridge/core/adapter-registry.d.ts +122 -0
  36. package/bridge/core/adapter-registry.d.ts.map +1 -0
  37. package/bridge/core/bridge-factory.d.ts +199 -0
  38. package/bridge/core/bridge-factory.d.ts.map +1 -0
  39. package/bridge/core/index.d.ts +10 -0
  40. package/bridge/core/index.d.ts.map +1 -0
  41. package/bridge/index.d.ts +62 -0
  42. package/bridge/index.d.ts.map +1 -0
  43. package/bridge/index.js +2540 -0
  44. package/bridge/runtime/iife-generator.d.ts +62 -0
  45. package/bridge/runtime/iife-generator.d.ts.map +1 -0
  46. package/bridge/runtime/index.d.ts +9 -0
  47. package/bridge/runtime/index.d.ts.map +1 -0
  48. package/bridge/types.d.ts +386 -0
  49. package/bridge/types.d.ts.map +1 -0
  50. package/build/cdn-resources.d.ts +243 -0
  51. package/build/cdn-resources.d.ts.map +1 -0
  52. package/build/index.d.ts +295 -0
  53. package/build/index.d.ts.map +1 -0
  54. package/build/index.js +7096 -0
  55. package/build/widget-manifest.d.ts +362 -0
  56. package/build/widget-manifest.d.ts.map +1 -0
  57. package/bundler/bundler.d.ts +208 -0
  58. package/bundler/bundler.d.ts.map +1 -0
  59. package/bundler/cache.d.ts +173 -0
  60. package/bundler/cache.d.ts.map +1 -0
  61. package/bundler/file-cache/component-builder.d.ts +167 -0
  62. package/bundler/file-cache/component-builder.d.ts.map +1 -0
  63. package/bundler/file-cache/hash-calculator.d.ts +155 -0
  64. package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  65. package/bundler/file-cache/index.d.ts +12 -0
  66. package/bundler/file-cache/index.d.ts.map +1 -0
  67. package/bundler/file-cache/storage/filesystem.d.ts +149 -0
  68. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  69. package/bundler/file-cache/storage/index.d.ts +11 -0
  70. package/bundler/file-cache/storage/index.d.ts.map +1 -0
  71. package/bundler/file-cache/storage/interface.d.ts +152 -0
  72. package/bundler/file-cache/storage/interface.d.ts.map +1 -0
  73. package/bundler/file-cache/storage/redis.d.ts +139 -0
  74. package/bundler/file-cache/storage/redis.d.ts.map +1 -0
  75. package/bundler/index.d.ts +43 -0
  76. package/bundler/index.d.ts.map +1 -0
  77. package/bundler/index.js +4754 -0
  78. package/bundler/sandbox/enclave-adapter.d.ts +121 -0
  79. package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  80. package/bundler/sandbox/executor.d.ts +14 -0
  81. package/bundler/sandbox/executor.d.ts.map +1 -0
  82. package/bundler/sandbox/policy.d.ts +62 -0
  83. package/bundler/sandbox/policy.d.ts.map +1 -0
  84. package/bundler/types.d.ts +702 -0
  85. package/bundler/types.d.ts.map +1 -0
  86. package/components/alert.d.ts +66 -0
  87. package/components/alert.d.ts.map +1 -0
  88. package/components/alert.schema.d.ts +98 -0
  89. package/components/alert.schema.d.ts.map +1 -0
  90. package/components/avatar.d.ts +77 -0
  91. package/components/avatar.d.ts.map +1 -0
  92. package/components/avatar.schema.d.ts +170 -0
  93. package/components/avatar.schema.d.ts.map +1 -0
  94. package/components/badge.d.ts +64 -0
  95. package/components/badge.d.ts.map +1 -0
  96. package/components/badge.schema.d.ts +91 -0
  97. package/components/badge.schema.d.ts.map +1 -0
  98. package/components/button.d.ts +100 -0
  99. package/components/button.d.ts.map +1 -0
  100. package/components/button.schema.d.ts +120 -0
  101. package/components/button.schema.d.ts.map +1 -0
  102. package/components/card.d.ts +53 -0
  103. package/components/card.d.ts.map +1 -0
  104. package/components/card.schema.d.ts +93 -0
  105. package/components/card.schema.d.ts.map +1 -0
  106. package/components/form.d.ts +212 -0
  107. package/components/form.d.ts.map +1 -0
  108. package/components/form.schema.d.ts +365 -0
  109. package/components/form.schema.d.ts.map +1 -0
  110. package/components/index.d.ts +29 -0
  111. package/components/index.d.ts.map +1 -0
  112. package/components/index.js +2595 -0
  113. package/components/list.d.ts +121 -0
  114. package/components/list.d.ts.map +1 -0
  115. package/components/list.schema.d.ts +129 -0
  116. package/components/list.schema.d.ts.map +1 -0
  117. package/components/modal.d.ts +100 -0
  118. package/components/modal.d.ts.map +1 -0
  119. package/components/modal.schema.d.ts +151 -0
  120. package/components/modal.schema.d.ts.map +1 -0
  121. package/components/table.d.ts +91 -0
  122. package/components/table.d.ts.map +1 -0
  123. package/components/table.schema.d.ts +123 -0
  124. package/components/table.schema.d.ts.map +1 -0
  125. package/dependency/cdn-registry.d.ts +98 -0
  126. package/dependency/cdn-registry.d.ts.map +1 -0
  127. package/dependency/import-map.d.ts +186 -0
  128. package/dependency/import-map.d.ts.map +1 -0
  129. package/dependency/import-parser.d.ts +82 -0
  130. package/dependency/import-parser.d.ts.map +1 -0
  131. package/dependency/index.d.ts +17 -0
  132. package/dependency/index.d.ts.map +1 -0
  133. package/dependency/resolver.d.ts +164 -0
  134. package/dependency/resolver.d.ts.map +1 -0
  135. package/dependency/schemas.d.ts +486 -0
  136. package/dependency/schemas.d.ts.map +1 -0
  137. package/dependency/template-loader.d.ts +204 -0
  138. package/dependency/template-loader.d.ts.map +1 -0
  139. package/dependency/template-processor.d.ts +118 -0
  140. package/dependency/template-processor.d.ts.map +1 -0
  141. package/dependency/types.d.ts +739 -0
  142. package/dependency/types.d.ts.map +1 -0
  143. package/esm/adapters/index.d.ts +13 -0
  144. package/esm/adapters/index.d.ts.map +1 -0
  145. package/esm/adapters/index.js +427 -0
  146. package/esm/adapters/platform-meta.d.ts +166 -0
  147. package/esm/adapters/platform-meta.d.ts.map +1 -0
  148. package/esm/adapters/response-builder.d.ts +108 -0
  149. package/esm/adapters/response-builder.d.ts.map +1 -0
  150. package/esm/adapters/serving-mode.d.ts +107 -0
  151. package/esm/adapters/serving-mode.d.ts.map +1 -0
  152. package/esm/base-template/bridge.d.ts +90 -0
  153. package/esm/base-template/bridge.d.ts.map +1 -0
  154. package/esm/base-template/default-base-template.d.ts +92 -0
  155. package/esm/base-template/default-base-template.d.ts.map +1 -0
  156. package/esm/base-template/index.d.ts +15 -0
  157. package/esm/base-template/index.d.ts.map +1 -0
  158. package/esm/base-template/index.js +1364 -0
  159. package/esm/base-template/polyfills.d.ts +31 -0
  160. package/esm/base-template/polyfills.d.ts.map +1 -0
  161. package/esm/base-template/theme-styles.d.ts +74 -0
  162. package/esm/base-template/theme-styles.d.ts.map +1 -0
  163. package/esm/bridge/adapters/base-adapter.d.ts +104 -0
  164. package/esm/bridge/adapters/base-adapter.d.ts.map +1 -0
  165. package/esm/bridge/adapters/claude.adapter.d.ts +67 -0
  166. package/esm/bridge/adapters/claude.adapter.d.ts.map +1 -0
  167. package/esm/bridge/adapters/ext-apps.adapter.d.ts +143 -0
  168. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
  169. package/esm/bridge/adapters/gemini.adapter.d.ts +64 -0
  170. package/esm/bridge/adapters/gemini.adapter.d.ts.map +1 -0
  171. package/esm/bridge/adapters/generic.adapter.d.ts +56 -0
  172. package/esm/bridge/adapters/generic.adapter.d.ts.map +1 -0
  173. package/esm/bridge/adapters/index.d.ts +26 -0
  174. package/esm/bridge/adapters/index.d.ts.map +1 -0
  175. package/esm/bridge/adapters/openai.adapter.d.ts +65 -0
  176. package/esm/bridge/adapters/openai.adapter.d.ts.map +1 -0
  177. package/esm/bridge/core/adapter-registry.d.ts +122 -0
  178. package/esm/bridge/core/adapter-registry.d.ts.map +1 -0
  179. package/esm/bridge/core/bridge-factory.d.ts +199 -0
  180. package/esm/bridge/core/bridge-factory.d.ts.map +1 -0
  181. package/esm/bridge/core/index.d.ts +10 -0
  182. package/esm/bridge/core/index.d.ts.map +1 -0
  183. package/esm/bridge/index.d.ts +62 -0
  184. package/esm/bridge/index.d.ts.map +1 -0
  185. package/esm/bridge/index.js +2487 -0
  186. package/esm/bridge/runtime/iife-generator.d.ts +62 -0
  187. package/esm/bridge/runtime/iife-generator.d.ts.map +1 -0
  188. package/esm/bridge/runtime/index.d.ts +9 -0
  189. package/esm/bridge/runtime/index.d.ts.map +1 -0
  190. package/esm/bridge/types.d.ts +386 -0
  191. package/esm/bridge/types.d.ts.map +1 -0
  192. package/esm/build/cdn-resources.d.ts +243 -0
  193. package/esm/build/cdn-resources.d.ts.map +1 -0
  194. package/esm/build/index.d.ts +295 -0
  195. package/esm/build/index.d.ts.map +1 -0
  196. package/esm/build/index.js +7021 -0
  197. package/esm/build/widget-manifest.d.ts +362 -0
  198. package/esm/build/widget-manifest.d.ts.map +1 -0
  199. package/esm/bundler/bundler.d.ts +208 -0
  200. package/esm/bundler/bundler.d.ts.map +1 -0
  201. package/esm/bundler/cache.d.ts +173 -0
  202. package/esm/bundler/cache.d.ts.map +1 -0
  203. package/esm/bundler/file-cache/component-builder.d.ts +167 -0
  204. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
  205. package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
  206. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  207. package/esm/bundler/file-cache/index.d.ts +12 -0
  208. package/esm/bundler/file-cache/index.d.ts.map +1 -0
  209. package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
  210. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  211. package/esm/bundler/file-cache/storage/index.d.ts +11 -0
  212. package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
  213. package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
  214. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
  215. package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
  216. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
  217. package/esm/bundler/index.d.ts +43 -0
  218. package/esm/bundler/index.d.ts.map +1 -0
  219. package/esm/bundler/index.js +4687 -0
  220. package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
  221. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  222. package/esm/bundler/sandbox/executor.d.ts +14 -0
  223. package/esm/bundler/sandbox/executor.d.ts.map +1 -0
  224. package/esm/bundler/sandbox/policy.d.ts +62 -0
  225. package/esm/bundler/sandbox/policy.d.ts.map +1 -0
  226. package/esm/bundler/types.d.ts +702 -0
  227. package/esm/bundler/types.d.ts.map +1 -0
  228. package/esm/components/alert.d.ts +66 -0
  229. package/esm/components/alert.d.ts.map +1 -0
  230. package/esm/components/alert.schema.d.ts +98 -0
  231. package/esm/components/alert.schema.d.ts.map +1 -0
  232. package/esm/components/avatar.d.ts +77 -0
  233. package/esm/components/avatar.d.ts.map +1 -0
  234. package/esm/components/avatar.schema.d.ts +170 -0
  235. package/esm/components/avatar.schema.d.ts.map +1 -0
  236. package/esm/components/badge.d.ts +64 -0
  237. package/esm/components/badge.d.ts.map +1 -0
  238. package/esm/components/badge.schema.d.ts +91 -0
  239. package/esm/components/badge.schema.d.ts.map +1 -0
  240. package/esm/components/button.d.ts +100 -0
  241. package/esm/components/button.d.ts.map +1 -0
  242. package/esm/components/button.schema.d.ts +120 -0
  243. package/esm/components/button.schema.d.ts.map +1 -0
  244. package/esm/components/card.d.ts +53 -0
  245. package/esm/components/card.d.ts.map +1 -0
  246. package/esm/components/card.schema.d.ts +93 -0
  247. package/esm/components/card.schema.d.ts.map +1 -0
  248. package/esm/components/form.d.ts +212 -0
  249. package/esm/components/form.d.ts.map +1 -0
  250. package/esm/components/form.schema.d.ts +365 -0
  251. package/esm/components/form.schema.d.ts.map +1 -0
  252. package/esm/components/index.d.ts +29 -0
  253. package/esm/components/index.d.ts.map +1 -0
  254. package/esm/components/index.js +2456 -0
  255. package/esm/components/list.d.ts +121 -0
  256. package/esm/components/list.d.ts.map +1 -0
  257. package/esm/components/list.schema.d.ts +129 -0
  258. package/esm/components/list.schema.d.ts.map +1 -0
  259. package/esm/components/modal.d.ts +100 -0
  260. package/esm/components/modal.d.ts.map +1 -0
  261. package/esm/components/modal.schema.d.ts +151 -0
  262. package/esm/components/modal.schema.d.ts.map +1 -0
  263. package/esm/components/table.d.ts +91 -0
  264. package/esm/components/table.d.ts.map +1 -0
  265. package/esm/components/table.schema.d.ts +123 -0
  266. package/esm/components/table.schema.d.ts.map +1 -0
  267. package/esm/dependency/cdn-registry.d.ts +98 -0
  268. package/esm/dependency/cdn-registry.d.ts.map +1 -0
  269. package/esm/dependency/import-map.d.ts +186 -0
  270. package/esm/dependency/import-map.d.ts.map +1 -0
  271. package/esm/dependency/import-parser.d.ts +82 -0
  272. package/esm/dependency/import-parser.d.ts.map +1 -0
  273. package/esm/dependency/index.d.ts +17 -0
  274. package/esm/dependency/index.d.ts.map +1 -0
  275. package/esm/dependency/resolver.d.ts +164 -0
  276. package/esm/dependency/resolver.d.ts.map +1 -0
  277. package/esm/dependency/schemas.d.ts +486 -0
  278. package/esm/dependency/schemas.d.ts.map +1 -0
  279. package/esm/dependency/template-loader.d.ts +204 -0
  280. package/esm/dependency/template-loader.d.ts.map +1 -0
  281. package/esm/dependency/template-processor.d.ts +118 -0
  282. package/esm/dependency/template-processor.d.ts.map +1 -0
  283. package/esm/dependency/types.d.ts +739 -0
  284. package/esm/dependency/types.d.ts.map +1 -0
  285. package/esm/handlebars/expression-extractor.d.ts +147 -0
  286. package/esm/handlebars/expression-extractor.d.ts.map +1 -0
  287. package/esm/handlebars/helpers.d.ts +339 -0
  288. package/esm/handlebars/helpers.d.ts.map +1 -0
  289. package/esm/handlebars/index.d.ts +195 -0
  290. package/esm/handlebars/index.d.ts.map +1 -0
  291. package/esm/handlebars/index.js +587 -0
  292. package/esm/index.d.ts +56 -0
  293. package/esm/index.d.ts.map +1 -0
  294. package/esm/index.js +20511 -0
  295. package/esm/layouts/base.d.ts +86 -0
  296. package/esm/layouts/base.d.ts.map +1 -0
  297. package/esm/layouts/index.d.ts +8 -0
  298. package/esm/layouts/index.d.ts.map +1 -0
  299. package/esm/layouts/index.js +892 -0
  300. package/esm/layouts/presets.d.ts +134 -0
  301. package/esm/layouts/presets.d.ts.map +1 -0
  302. package/esm/package.json +90 -0
  303. package/esm/pages/consent.d.ts +117 -0
  304. package/esm/pages/consent.d.ts.map +1 -0
  305. package/esm/pages/error.d.ts +101 -0
  306. package/esm/pages/error.d.ts.map +1 -0
  307. package/esm/pages/index.d.ts +9 -0
  308. package/esm/pages/index.d.ts.map +1 -0
  309. package/esm/pages/index.js +1563 -0
  310. package/esm/react/Alert.d.ts +102 -0
  311. package/esm/react/Alert.d.ts.map +1 -0
  312. package/esm/react/Badge.d.ts +101 -0
  313. package/esm/react/Badge.d.ts.map +1 -0
  314. package/esm/react/Button.d.ts +109 -0
  315. package/esm/react/Button.d.ts.map +1 -0
  316. package/esm/react/Card.d.ts +104 -0
  317. package/esm/react/Card.d.ts.map +1 -0
  318. package/esm/react/hooks/context.d.ts +179 -0
  319. package/esm/react/hooks/context.d.ts.map +1 -0
  320. package/esm/react/hooks/index.d.ts +42 -0
  321. package/esm/react/hooks/index.d.ts.map +1 -0
  322. package/esm/react/hooks/tools.d.ts +284 -0
  323. package/esm/react/hooks/tools.d.ts.map +1 -0
  324. package/esm/react/index.d.ts +81 -0
  325. package/esm/react/index.d.ts.map +1 -0
  326. package/esm/react/index.js +1372 -0
  327. package/esm/react/types.d.ts +106 -0
  328. package/esm/react/types.d.ts.map +1 -0
  329. package/esm/react/utils.d.ts +43 -0
  330. package/esm/react/utils.d.ts.map +1 -0
  331. package/esm/registry/index.d.ts +46 -0
  332. package/esm/registry/index.d.ts.map +1 -0
  333. package/esm/registry/index.js +6422 -0
  334. package/esm/registry/render-template.d.ts +91 -0
  335. package/esm/registry/render-template.d.ts.map +1 -0
  336. package/esm/registry/tool-ui.registry.d.ts +294 -0
  337. package/esm/registry/tool-ui.registry.d.ts.map +1 -0
  338. package/esm/registry/uri-utils.d.ts +56 -0
  339. package/esm/registry/uri-utils.d.ts.map +1 -0
  340. package/esm/render/index.d.ts +8 -0
  341. package/esm/render/index.d.ts.map +1 -0
  342. package/esm/render/index.js +45 -0
  343. package/esm/render/prerender.d.ts +57 -0
  344. package/esm/render/prerender.d.ts.map +1 -0
  345. package/esm/renderers/cache.d.ts +145 -0
  346. package/esm/renderers/cache.d.ts.map +1 -0
  347. package/esm/renderers/html.renderer.d.ts +123 -0
  348. package/esm/renderers/html.renderer.d.ts.map +1 -0
  349. package/esm/renderers/index.d.ts +36 -0
  350. package/esm/renderers/index.d.ts.map +1 -0
  351. package/esm/renderers/index.js +1827 -0
  352. package/esm/renderers/mdx.renderer.d.ts +120 -0
  353. package/esm/renderers/mdx.renderer.d.ts.map +1 -0
  354. package/esm/renderers/react.renderer.d.ts +96 -0
  355. package/esm/renderers/react.renderer.d.ts.map +1 -0
  356. package/esm/renderers/registry.d.ts +134 -0
  357. package/esm/renderers/registry.d.ts.map +1 -0
  358. package/esm/renderers/types.d.ts +342 -0
  359. package/esm/renderers/types.d.ts.map +1 -0
  360. package/esm/renderers/utils/detect.d.ts +107 -0
  361. package/esm/renderers/utils/detect.d.ts.map +1 -0
  362. package/esm/renderers/utils/hash.d.ts +40 -0
  363. package/esm/renderers/utils/hash.d.ts.map +1 -0
  364. package/esm/renderers/utils/index.d.ts +9 -0
  365. package/esm/renderers/utils/index.d.ts.map +1 -0
  366. package/esm/renderers/utils/transpiler.d.ts +89 -0
  367. package/esm/renderers/utils/transpiler.d.ts.map +1 -0
  368. package/esm/runtime/adapters/html.adapter.d.ts +59 -0
  369. package/esm/runtime/adapters/html.adapter.d.ts.map +1 -0
  370. package/esm/runtime/adapters/index.d.ts +26 -0
  371. package/esm/runtime/adapters/index.d.ts.map +1 -0
  372. package/esm/runtime/adapters/mdx.adapter.d.ts +73 -0
  373. package/esm/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  374. package/esm/runtime/adapters/react.adapter.d.ts +70 -0
  375. package/esm/runtime/adapters/react.adapter.d.ts.map +1 -0
  376. package/esm/runtime/adapters/types.d.ts +95 -0
  377. package/esm/runtime/adapters/types.d.ts.map +1 -0
  378. package/esm/runtime/csp.d.ts +48 -0
  379. package/esm/runtime/csp.d.ts.map +1 -0
  380. package/esm/runtime/index.d.ts +17 -0
  381. package/esm/runtime/index.d.ts.map +1 -0
  382. package/esm/runtime/index.js +5186 -0
  383. package/esm/runtime/mcp-bridge.d.ts +101 -0
  384. package/esm/runtime/mcp-bridge.d.ts.map +1 -0
  385. package/esm/runtime/renderer-runtime.d.ts +133 -0
  386. package/esm/runtime/renderer-runtime.d.ts.map +1 -0
  387. package/esm/runtime/sanitizer.d.ts +172 -0
  388. package/esm/runtime/sanitizer.d.ts.map +1 -0
  389. package/esm/runtime/types.d.ts +415 -0
  390. package/esm/runtime/types.d.ts.map +1 -0
  391. package/esm/runtime/wrapper.d.ts +421 -0
  392. package/esm/runtime/wrapper.d.ts.map +1 -0
  393. package/esm/styles/index.d.ts +8 -0
  394. package/esm/styles/index.d.ts.map +1 -0
  395. package/esm/styles/index.js +171 -0
  396. package/esm/styles/variants.d.ts +51 -0
  397. package/esm/styles/variants.d.ts.map +1 -0
  398. package/esm/theme/cdn.d.ts +195 -0
  399. package/esm/theme/cdn.d.ts.map +1 -0
  400. package/esm/theme/index.d.ts +18 -0
  401. package/esm/theme/index.d.ts.map +1 -0
  402. package/esm/theme/index.js +700 -0
  403. package/esm/theme/platforms.d.ts +107 -0
  404. package/esm/theme/platforms.d.ts.map +1 -0
  405. package/esm/theme/presets/github-openai.d.ts +50 -0
  406. package/esm/theme/presets/github-openai.d.ts.map +1 -0
  407. package/esm/theme/presets/index.d.ts +11 -0
  408. package/esm/theme/presets/index.d.ts.map +1 -0
  409. package/esm/theme/theme.d.ts +396 -0
  410. package/esm/theme/theme.d.ts.map +1 -0
  411. package/esm/tool-template/builder.d.ts +213 -0
  412. package/esm/tool-template/builder.d.ts.map +1 -0
  413. package/esm/tool-template/index.d.ts +16 -0
  414. package/esm/tool-template/index.d.ts.map +1 -0
  415. package/esm/tool-template/index.js +3515 -0
  416. package/esm/types/index.d.ts +14 -0
  417. package/esm/types/index.d.ts.map +1 -0
  418. package/esm/types/index.js +75 -0
  419. package/esm/types/ui-config.d.ts +639 -0
  420. package/esm/types/ui-config.d.ts.map +1 -0
  421. package/esm/types/ui-runtime.d.ts +1007 -0
  422. package/esm/types/ui-runtime.d.ts.map +1 -0
  423. package/esm/typings/cache/cache-adapter.d.ts +125 -0
  424. package/esm/typings/cache/cache-adapter.d.ts.map +1 -0
  425. package/esm/typings/cache/index.d.ts +10 -0
  426. package/esm/typings/cache/index.d.ts.map +1 -0
  427. package/esm/typings/cache/memory-cache.d.ts +92 -0
  428. package/esm/typings/cache/memory-cache.d.ts.map +1 -0
  429. package/esm/typings/dts-parser.d.ts +90 -0
  430. package/esm/typings/dts-parser.d.ts.map +1 -0
  431. package/esm/typings/index.d.ts +48 -0
  432. package/esm/typings/index.d.ts.map +1 -0
  433. package/esm/typings/schemas.d.ts +232 -0
  434. package/esm/typings/schemas.d.ts.map +1 -0
  435. package/esm/typings/type-fetcher.d.ts +89 -0
  436. package/esm/typings/type-fetcher.d.ts.map +1 -0
  437. package/esm/typings/types.d.ts +320 -0
  438. package/esm/typings/types.d.ts.map +1 -0
  439. package/esm/universal/UniversalApp.d.ts +108 -0
  440. package/esm/universal/UniversalApp.d.ts.map +1 -0
  441. package/esm/universal/cached-runtime.d.ts +115 -0
  442. package/esm/universal/cached-runtime.d.ts.map +1 -0
  443. package/esm/universal/context.d.ts +122 -0
  444. package/esm/universal/context.d.ts.map +1 -0
  445. package/esm/universal/index.d.ts +57 -0
  446. package/esm/universal/index.d.ts.map +1 -0
  447. package/esm/universal/renderers/html.renderer.d.ts +37 -0
  448. package/esm/universal/renderers/html.renderer.d.ts.map +1 -0
  449. package/esm/universal/renderers/index.d.ts +112 -0
  450. package/esm/universal/renderers/index.d.ts.map +1 -0
  451. package/esm/universal/renderers/markdown.renderer.d.ts +33 -0
  452. package/esm/universal/renderers/markdown.renderer.d.ts.map +1 -0
  453. package/esm/universal/renderers/mdx.renderer.d.ts +38 -0
  454. package/esm/universal/renderers/mdx.renderer.d.ts.map +1 -0
  455. package/esm/universal/renderers/react.renderer.d.ts +46 -0
  456. package/esm/universal/renderers/react.renderer.d.ts.map +1 -0
  457. package/esm/universal/runtime-builder.d.ts +33 -0
  458. package/esm/universal/runtime-builder.d.ts.map +1 -0
  459. package/esm/universal/store.d.ts +135 -0
  460. package/esm/universal/store.d.ts.map +1 -0
  461. package/esm/universal/types.d.ts +199 -0
  462. package/esm/universal/types.d.ts.map +1 -0
  463. package/esm/utils/escape-html.d.ts +58 -0
  464. package/esm/utils/escape-html.d.ts.map +1 -0
  465. package/esm/utils/index.d.ts +10 -0
  466. package/esm/utils/index.d.ts.map +1 -0
  467. package/esm/utils/index.js +40 -0
  468. package/esm/utils/safe-stringify.d.ts +30 -0
  469. package/esm/utils/safe-stringify.d.ts.map +1 -0
  470. package/esm/validation/error-box.d.ts +56 -0
  471. package/esm/validation/error-box.d.ts.map +1 -0
  472. package/esm/validation/index.d.ts +13 -0
  473. package/esm/validation/index.d.ts.map +1 -0
  474. package/esm/validation/index.js +562 -0
  475. package/esm/validation/schema-paths.d.ts +118 -0
  476. package/esm/validation/schema-paths.d.ts.map +1 -0
  477. package/esm/validation/template-validator.d.ts +143 -0
  478. package/esm/validation/template-validator.d.ts.map +1 -0
  479. package/esm/validation/wrapper.d.ts +97 -0
  480. package/esm/validation/wrapper.d.ts.map +1 -0
  481. package/esm/web-components/core/attribute-parser.d.ts +82 -0
  482. package/esm/web-components/core/attribute-parser.d.ts.map +1 -0
  483. package/esm/web-components/core/base-element.d.ts +197 -0
  484. package/esm/web-components/core/base-element.d.ts.map +1 -0
  485. package/esm/web-components/core/index.d.ts +9 -0
  486. package/esm/web-components/core/index.d.ts.map +1 -0
  487. package/esm/web-components/elements/fmcp-alert.d.ts +46 -0
  488. package/esm/web-components/elements/fmcp-alert.d.ts.map +1 -0
  489. package/esm/web-components/elements/fmcp-badge.d.ts +47 -0
  490. package/esm/web-components/elements/fmcp-badge.d.ts.map +1 -0
  491. package/esm/web-components/elements/fmcp-button.d.ts +117 -0
  492. package/esm/web-components/elements/fmcp-button.d.ts.map +1 -0
  493. package/esm/web-components/elements/fmcp-card.d.ts +53 -0
  494. package/esm/web-components/elements/fmcp-card.d.ts.map +1 -0
  495. package/esm/web-components/elements/fmcp-input.d.ts +96 -0
  496. package/esm/web-components/elements/fmcp-input.d.ts.map +1 -0
  497. package/esm/web-components/elements/fmcp-select.d.ts +100 -0
  498. package/esm/web-components/elements/fmcp-select.d.ts.map +1 -0
  499. package/esm/web-components/elements/index.d.ts +13 -0
  500. package/esm/web-components/elements/index.d.ts.map +1 -0
  501. package/esm/web-components/index.d.ts +50 -0
  502. package/esm/web-components/index.d.ts.map +1 -0
  503. package/esm/web-components/index.js +2048 -0
  504. package/esm/web-components/register.d.ts +57 -0
  505. package/esm/web-components/register.d.ts.map +1 -0
  506. package/esm/web-components/types.d.ts +122 -0
  507. package/esm/web-components/types.d.ts.map +1 -0
  508. package/esm/widgets/index.d.ts +8 -0
  509. package/esm/widgets/index.d.ts.map +1 -0
  510. package/esm/widgets/index.js +941 -0
  511. package/esm/widgets/progress.d.ts +133 -0
  512. package/esm/widgets/progress.d.ts.map +1 -0
  513. package/esm/widgets/resource.d.ts +163 -0
  514. package/esm/widgets/resource.d.ts.map +1 -0
  515. package/handlebars/expression-extractor.d.ts +147 -0
  516. package/handlebars/expression-extractor.d.ts.map +1 -0
  517. package/handlebars/helpers.d.ts +339 -0
  518. package/handlebars/helpers.d.ts.map +1 -0
  519. package/handlebars/index.d.ts +195 -0
  520. package/handlebars/index.d.ts.map +1 -0
  521. package/handlebars/index.js +666 -0
  522. package/index.d.ts +56 -0
  523. package/index.d.ts.map +1 -0
  524. package/index.js +20942 -0
  525. package/layouts/base.d.ts +86 -0
  526. package/layouts/base.d.ts.map +1 -0
  527. package/layouts/index.d.ts +8 -0
  528. package/layouts/index.d.ts.map +1 -0
  529. package/layouts/index.js +930 -0
  530. package/layouts/presets.d.ts +134 -0
  531. package/layouts/presets.d.ts.map +1 -0
  532. package/package.json +28 -87
  533. package/pages/consent.d.ts +117 -0
  534. package/pages/consent.d.ts.map +1 -0
  535. package/pages/error.d.ts +101 -0
  536. package/pages/error.d.ts.map +1 -0
  537. package/pages/index.d.ts +9 -0
  538. package/pages/index.d.ts.map +1 -0
  539. package/pages/index.js +1602 -0
  540. package/react/Alert.d.ts +102 -0
  541. package/react/Alert.d.ts.map +1 -0
  542. package/react/Badge.d.ts +101 -0
  543. package/react/Badge.d.ts.map +1 -0
  544. package/react/Button.d.ts +109 -0
  545. package/react/Button.d.ts.map +1 -0
  546. package/react/Card.d.ts +104 -0
  547. package/react/Card.d.ts.map +1 -0
  548. package/react/hooks/context.d.ts +179 -0
  549. package/react/hooks/context.d.ts.map +1 -0
  550. package/react/hooks/index.d.ts +42 -0
  551. package/react/hooks/index.d.ts.map +1 -0
  552. package/react/hooks/tools.d.ts +284 -0
  553. package/react/hooks/tools.d.ts.map +1 -0
  554. package/react/index.d.ts +81 -0
  555. package/react/index.d.ts.map +1 -0
  556. package/react/index.js +1430 -0
  557. package/react/types.d.ts +106 -0
  558. package/react/types.d.ts.map +1 -0
  559. package/react/utils.d.ts +43 -0
  560. package/react/utils.d.ts.map +1 -0
  561. package/registry/index.d.ts +46 -0
  562. package/registry/index.d.ts.map +1 -0
  563. package/registry/index.js +6465 -0
  564. package/registry/render-template.d.ts +91 -0
  565. package/registry/render-template.d.ts.map +1 -0
  566. package/registry/tool-ui.registry.d.ts +294 -0
  567. package/registry/tool-ui.registry.d.ts.map +1 -0
  568. package/registry/uri-utils.d.ts +56 -0
  569. package/registry/uri-utils.d.ts.map +1 -0
  570. package/render/index.d.ts +8 -0
  571. package/render/index.d.ts.map +1 -0
  572. package/render/index.js +77 -0
  573. package/render/prerender.d.ts +57 -0
  574. package/render/prerender.d.ts.map +1 -0
  575. package/renderers/cache.d.ts +145 -0
  576. package/renderers/cache.d.ts.map +1 -0
  577. package/renderers/html.renderer.d.ts +123 -0
  578. package/renderers/html.renderer.d.ts.map +1 -0
  579. package/renderers/index.d.ts +36 -0
  580. package/renderers/index.d.ts.map +1 -0
  581. package/renderers/index.js +1882 -0
  582. package/renderers/mdx.renderer.d.ts +120 -0
  583. package/renderers/mdx.renderer.d.ts.map +1 -0
  584. package/renderers/react.renderer.d.ts +96 -0
  585. package/renderers/react.renderer.d.ts.map +1 -0
  586. package/renderers/registry.d.ts +134 -0
  587. package/renderers/registry.d.ts.map +1 -0
  588. package/renderers/types.d.ts +342 -0
  589. package/renderers/types.d.ts.map +1 -0
  590. package/renderers/utils/detect.d.ts +107 -0
  591. package/renderers/utils/detect.d.ts.map +1 -0
  592. package/renderers/utils/hash.d.ts +40 -0
  593. package/renderers/utils/hash.d.ts.map +1 -0
  594. package/renderers/utils/index.d.ts +9 -0
  595. package/renderers/utils/index.d.ts.map +1 -0
  596. package/renderers/utils/transpiler.d.ts +89 -0
  597. package/renderers/utils/transpiler.d.ts.map +1 -0
  598. package/runtime/adapters/html.adapter.d.ts +59 -0
  599. package/runtime/adapters/html.adapter.d.ts.map +1 -0
  600. package/runtime/adapters/index.d.ts +26 -0
  601. package/runtime/adapters/index.d.ts.map +1 -0
  602. package/runtime/adapters/mdx.adapter.d.ts +73 -0
  603. package/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  604. package/runtime/adapters/react.adapter.d.ts +70 -0
  605. package/runtime/adapters/react.adapter.d.ts.map +1 -0
  606. package/runtime/adapters/types.d.ts +95 -0
  607. package/runtime/adapters/types.d.ts.map +1 -0
  608. package/runtime/csp.d.ts +48 -0
  609. package/runtime/csp.d.ts.map +1 -0
  610. package/runtime/index.d.ts +17 -0
  611. package/runtime/index.d.ts.map +1 -0
  612. package/runtime/index.js +5264 -0
  613. package/runtime/mcp-bridge.d.ts +101 -0
  614. package/runtime/mcp-bridge.d.ts.map +1 -0
  615. package/runtime/renderer-runtime.d.ts +133 -0
  616. package/runtime/renderer-runtime.d.ts.map +1 -0
  617. package/runtime/sanitizer.d.ts +172 -0
  618. package/runtime/sanitizer.d.ts.map +1 -0
  619. package/runtime/types.d.ts +415 -0
  620. package/runtime/types.d.ts.map +1 -0
  621. package/runtime/wrapper.d.ts +421 -0
  622. package/runtime/wrapper.d.ts.map +1 -0
  623. package/styles/index.d.ts +8 -0
  624. package/styles/index.d.ts.map +1 -0
  625. package/styles/index.js +222 -0
  626. package/styles/variants.d.ts +51 -0
  627. package/styles/variants.d.ts.map +1 -0
  628. package/theme/cdn.d.ts +195 -0
  629. package/theme/cdn.d.ts.map +1 -0
  630. package/theme/index.d.ts +18 -0
  631. package/theme/index.d.ts.map +1 -0
  632. package/theme/index.js +757 -0
  633. package/theme/platforms.d.ts +107 -0
  634. package/theme/platforms.d.ts.map +1 -0
  635. package/theme/presets/github-openai.d.ts +50 -0
  636. package/theme/presets/github-openai.d.ts.map +1 -0
  637. package/theme/presets/index.d.ts +11 -0
  638. package/theme/presets/index.d.ts.map +1 -0
  639. package/theme/theme.d.ts +396 -0
  640. package/theme/theme.d.ts.map +1 -0
  641. package/tool-template/builder.d.ts +213 -0
  642. package/tool-template/builder.d.ts.map +1 -0
  643. package/tool-template/index.d.ts +16 -0
  644. package/tool-template/index.d.ts.map +1 -0
  645. package/tool-template/index.js +3559 -0
  646. package/types/index.d.ts +14 -0
  647. package/types/index.d.ts.map +1 -0
  648. package/types/index.js +108 -0
  649. package/types/ui-config.d.ts +639 -0
  650. package/types/ui-config.d.ts.map +1 -0
  651. package/types/ui-runtime.d.ts +1007 -0
  652. package/types/ui-runtime.d.ts.map +1 -0
  653. package/typings/cache/cache-adapter.d.ts +125 -0
  654. package/typings/cache/cache-adapter.d.ts.map +1 -0
  655. package/typings/cache/index.d.ts +10 -0
  656. package/typings/cache/index.d.ts.map +1 -0
  657. package/typings/cache/memory-cache.d.ts +92 -0
  658. package/typings/cache/memory-cache.d.ts.map +1 -0
  659. package/typings/dts-parser.d.ts +90 -0
  660. package/typings/dts-parser.d.ts.map +1 -0
  661. package/typings/index.d.ts +48 -0
  662. package/typings/index.d.ts.map +1 -0
  663. package/typings/schemas.d.ts +232 -0
  664. package/typings/schemas.d.ts.map +1 -0
  665. package/typings/type-fetcher.d.ts +89 -0
  666. package/typings/type-fetcher.d.ts.map +1 -0
  667. package/typings/types.d.ts +320 -0
  668. package/typings/types.d.ts.map +1 -0
  669. package/universal/UniversalApp.d.ts +108 -0
  670. package/universal/UniversalApp.d.ts.map +1 -0
  671. package/universal/cached-runtime.d.ts +115 -0
  672. package/universal/cached-runtime.d.ts.map +1 -0
  673. package/universal/context.d.ts +122 -0
  674. package/universal/context.d.ts.map +1 -0
  675. package/universal/index.d.ts +57 -0
  676. package/universal/index.d.ts.map +1 -0
  677. package/universal/renderers/html.renderer.d.ts +37 -0
  678. package/universal/renderers/html.renderer.d.ts.map +1 -0
  679. package/universal/renderers/index.d.ts +112 -0
  680. package/universal/renderers/index.d.ts.map +1 -0
  681. package/universal/renderers/markdown.renderer.d.ts +33 -0
  682. package/universal/renderers/markdown.renderer.d.ts.map +1 -0
  683. package/universal/renderers/mdx.renderer.d.ts +38 -0
  684. package/universal/renderers/mdx.renderer.d.ts.map +1 -0
  685. package/universal/renderers/react.renderer.d.ts +46 -0
  686. package/universal/renderers/react.renderer.d.ts.map +1 -0
  687. package/universal/runtime-builder.d.ts +33 -0
  688. package/universal/runtime-builder.d.ts.map +1 -0
  689. package/universal/store.d.ts +135 -0
  690. package/universal/store.d.ts.map +1 -0
  691. package/universal/types.d.ts +199 -0
  692. package/universal/types.d.ts.map +1 -0
  693. package/utils/escape-html.d.ts +58 -0
  694. package/utils/escape-html.d.ts.map +1 -0
  695. package/utils/index.d.ts +10 -0
  696. package/utils/index.d.ts.map +1 -0
  697. package/utils/index.js +70 -0
  698. package/utils/safe-stringify.d.ts +30 -0
  699. package/utils/safe-stringify.d.ts.map +1 -0
  700. package/validation/error-box.d.ts +56 -0
  701. package/validation/error-box.d.ts.map +1 -0
  702. package/validation/index.d.ts +13 -0
  703. package/validation/index.d.ts.map +1 -0
  704. package/validation/index.js +603 -0
  705. package/validation/schema-paths.d.ts +118 -0
  706. package/validation/schema-paths.d.ts.map +1 -0
  707. package/validation/template-validator.d.ts +143 -0
  708. package/validation/template-validator.d.ts.map +1 -0
  709. package/validation/wrapper.d.ts +97 -0
  710. package/validation/wrapper.d.ts.map +1 -0
  711. package/web-components/core/attribute-parser.d.ts +82 -0
  712. package/web-components/core/attribute-parser.d.ts.map +1 -0
  713. package/web-components/core/base-element.d.ts +197 -0
  714. package/web-components/core/base-element.d.ts.map +1 -0
  715. package/web-components/core/index.d.ts +9 -0
  716. package/web-components/core/index.d.ts.map +1 -0
  717. package/web-components/elements/fmcp-alert.d.ts +46 -0
  718. package/web-components/elements/fmcp-alert.d.ts.map +1 -0
  719. package/web-components/elements/fmcp-badge.d.ts +47 -0
  720. package/web-components/elements/fmcp-badge.d.ts.map +1 -0
  721. package/web-components/elements/fmcp-button.d.ts +117 -0
  722. package/web-components/elements/fmcp-button.d.ts.map +1 -0
  723. package/web-components/elements/fmcp-card.d.ts +53 -0
  724. package/web-components/elements/fmcp-card.d.ts.map +1 -0
  725. package/web-components/elements/fmcp-input.d.ts +96 -0
  726. package/web-components/elements/fmcp-input.d.ts.map +1 -0
  727. package/web-components/elements/fmcp-select.d.ts +100 -0
  728. package/web-components/elements/fmcp-select.d.ts.map +1 -0
  729. package/web-components/elements/index.d.ts +13 -0
  730. package/web-components/elements/index.d.ts.map +1 -0
  731. package/web-components/index.d.ts +50 -0
  732. package/web-components/index.d.ts.map +1 -0
  733. package/web-components/index.js +2093 -0
  734. package/web-components/register.d.ts +57 -0
  735. package/web-components/register.d.ts.map +1 -0
  736. package/web-components/types.d.ts +122 -0
  737. package/web-components/types.d.ts.map +1 -0
  738. package/widgets/index.d.ts +8 -0
  739. package/widgets/index.d.ts.map +1 -0
  740. package/widgets/index.js +978 -0
  741. package/widgets/progress.d.ts +133 -0
  742. package/widgets/progress.d.ts.map +1 -0
  743. package/widgets/resource.d.ts +163 -0
  744. package/widgets/resource.d.ts.map +1 -0
  745. package/src/adapters/index.d.ts +0 -10
  746. package/src/adapters/index.js +0 -18
  747. package/src/adapters/index.js.map +0 -1
  748. package/src/adapters/platform-meta.d.ts +0 -165
  749. package/src/adapters/platform-meta.js +0 -310
  750. package/src/adapters/platform-meta.js.map +0 -1
  751. package/src/base-template/bridge.d.ts +0 -89
  752. package/src/base-template/bridge.js +0 -452
  753. package/src/base-template/bridge.js.map +0 -1
  754. package/src/base-template/default-base-template.d.ts +0 -91
  755. package/src/base-template/default-base-template.js +0 -435
  756. package/src/base-template/default-base-template.js.map +0 -1
  757. package/src/base-template/index.d.ts +0 -14
  758. package/src/base-template/index.js +0 -30
  759. package/src/base-template/index.js.map +0 -1
  760. package/src/base-template/polyfills.d.ts +0 -30
  761. package/src/base-template/polyfills.js +0 -190
  762. package/src/base-template/polyfills.js.map +0 -1
  763. package/src/base-template/theme-styles.d.ts +0 -73
  764. package/src/base-template/theme-styles.js +0 -95
  765. package/src/base-template/theme-styles.js.map +0 -1
  766. package/src/bridge/adapters/base-adapter.d.ts +0 -103
  767. package/src/bridge/adapters/base-adapter.js +0 -314
  768. package/src/bridge/adapters/base-adapter.js.map +0 -1
  769. package/src/bridge/adapters/claude.adapter.d.ts +0 -66
  770. package/src/bridge/adapters/claude.adapter.js +0 -145
  771. package/src/bridge/adapters/claude.adapter.js.map +0 -1
  772. package/src/bridge/adapters/ext-apps.adapter.d.ts +0 -142
  773. package/src/bridge/adapters/ext-apps.adapter.js +0 -416
  774. package/src/bridge/adapters/ext-apps.adapter.js.map +0 -1
  775. package/src/bridge/adapters/gemini.adapter.d.ts +0 -63
  776. package/src/bridge/adapters/gemini.adapter.js +0 -160
  777. package/src/bridge/adapters/gemini.adapter.js.map +0 -1
  778. package/src/bridge/adapters/generic.adapter.d.ts +0 -55
  779. package/src/bridge/adapters/generic.adapter.js +0 -108
  780. package/src/bridge/adapters/generic.adapter.js.map +0 -1
  781. package/src/bridge/adapters/index.d.ts +0 -25
  782. package/src/bridge/adapters/index.js +0 -65
  783. package/src/bridge/adapters/index.js.map +0 -1
  784. package/src/bridge/adapters/openai.adapter.d.ts +0 -64
  785. package/src/bridge/adapters/openai.adapter.js +0 -194
  786. package/src/bridge/adapters/openai.adapter.js.map +0 -1
  787. package/src/bridge/core/adapter-registry.d.ts +0 -121
  788. package/src/bridge/core/adapter-registry.js +0 -271
  789. package/src/bridge/core/adapter-registry.js.map +0 -1
  790. package/src/bridge/core/bridge-factory.d.ts +0 -198
  791. package/src/bridge/core/bridge-factory.js +0 -428
  792. package/src/bridge/core/bridge-factory.js.map +0 -1
  793. package/src/bridge/core/index.d.ts +0 -9
  794. package/src/bridge/core/index.js +0 -22
  795. package/src/bridge/core/index.js.map +0 -1
  796. package/src/bridge/index.d.ts +0 -61
  797. package/src/bridge/index.js +0 -94
  798. package/src/bridge/index.js.map +0 -1
  799. package/src/bridge/runtime/iife-generator.d.ts +0 -61
  800. package/src/bridge/runtime/iife-generator.js +0 -940
  801. package/src/bridge/runtime/iife-generator.js.map +0 -1
  802. package/src/bridge/runtime/index.d.ts +0 -8
  803. package/src/bridge/runtime/index.js +0 -16
  804. package/src/bridge/runtime/index.js.map +0 -1
  805. package/src/bridge/types.d.ts +0 -385
  806. package/src/bridge/types.js +0 -11
  807. package/src/bridge/types.js.map +0 -1
  808. package/src/build/cdn-resources.d.ts +0 -140
  809. package/src/build/cdn-resources.js +0 -314
  810. package/src/build/cdn-resources.js.map +0 -1
  811. package/src/build/index.d.ts +0 -294
  812. package/src/build/index.js +0 -325
  813. package/src/build/index.js.map +0 -1
  814. package/src/build/widget-manifest.d.ts +0 -212
  815. package/src/build/widget-manifest.js +0 -652
  816. package/src/build/widget-manifest.js.map +0 -1
  817. package/src/bundler/bundler.d.ts +0 -110
  818. package/src/bundler/bundler.js +0 -432
  819. package/src/bundler/bundler.js.map +0 -1
  820. package/src/bundler/cache.d.ts +0 -172
  821. package/src/bundler/cache.js +0 -250
  822. package/src/bundler/cache.js.map +0 -1
  823. package/src/bundler/index.d.ts +0 -41
  824. package/src/bundler/index.js +0 -73
  825. package/src/bundler/index.js.map +0 -1
  826. package/src/bundler/sandbox/enclave-adapter.d.ts +0 -120
  827. package/src/bundler/sandbox/enclave-adapter.js +0 -339
  828. package/src/bundler/sandbox/enclave-adapter.js.map +0 -1
  829. package/src/bundler/sandbox/executor.d.ts +0 -13
  830. package/src/bundler/sandbox/executor.js +0 -22
  831. package/src/bundler/sandbox/executor.js.map +0 -1
  832. package/src/bundler/sandbox/policy.d.ts +0 -61
  833. package/src/bundler/sandbox/policy.js +0 -238
  834. package/src/bundler/sandbox/policy.js.map +0 -1
  835. package/src/bundler/types.d.ts +0 -347
  836. package/src/bundler/types.js +0 -132
  837. package/src/bundler/types.js.map +0 -1
  838. package/src/components/alert.d.ts +0 -71
  839. package/src/components/alert.js +0 -189
  840. package/src/components/alert.js.map +0 -1
  841. package/src/components/alert.schema.d.ts +0 -114
  842. package/src/components/alert.schema.js +0 -105
  843. package/src/components/alert.schema.js.map +0 -1
  844. package/src/components/avatar.d.ts +0 -76
  845. package/src/components/avatar.js +0 -176
  846. package/src/components/avatar.js.map +0 -1
  847. package/src/components/avatar.schema.d.ts +0 -169
  848. package/src/components/avatar.schema.js +0 -103
  849. package/src/components/avatar.schema.js.map +0 -1
  850. package/src/components/badge.d.ts +0 -70
  851. package/src/components/badge.js +0 -149
  852. package/src/components/badge.js.map +0 -1
  853. package/src/components/badge.schema.d.ts +0 -109
  854. package/src/components/badge.schema.js +0 -96
  855. package/src/components/badge.schema.js.map +0 -1
  856. package/src/components/button.d.ts +0 -111
  857. package/src/components/button.js +0 -336
  858. package/src/components/button.js.map +0 -1
  859. package/src/components/button.schema.d.ts +0 -148
  860. package/src/components/button.schema.js +0 -121
  861. package/src/components/button.schema.js.map +0 -1
  862. package/src/components/card.d.ts +0 -60
  863. package/src/components/card.js +0 -117
  864. package/src/components/card.js.map +0 -1
  865. package/src/components/card.schema.d.ts +0 -113
  866. package/src/components/card.schema.js +0 -98
  867. package/src/components/card.schema.js.map +0 -1
  868. package/src/components/form.d.ts +0 -239
  869. package/src/components/form.js +0 -420
  870. package/src/components/form.js.map +0 -1
  871. package/src/components/form.schema.d.ts +0 -441
  872. package/src/components/form.schema.js +0 -406
  873. package/src/components/form.schema.js.map +0 -1
  874. package/src/components/index.d.ts +0 -29
  875. package/src/components/index.js +0 -98
  876. package/src/components/index.js.map +0 -1
  877. package/src/components/list.d.ts +0 -127
  878. package/src/components/list.js +0 -279
  879. package/src/components/list.js.map +0 -1
  880. package/src/components/list.schema.d.ts +0 -134
  881. package/src/components/list.schema.js +0 -168
  882. package/src/components/list.schema.js.map +0 -1
  883. package/src/components/modal.d.ts +0 -111
  884. package/src/components/modal.js +0 -260
  885. package/src/components/modal.js.map +0 -1
  886. package/src/components/modal.schema.d.ts +0 -186
  887. package/src/components/modal.schema.js +0 -167
  888. package/src/components/modal.schema.js.map +0 -1
  889. package/src/components/table.d.ts +0 -105
  890. package/src/components/table.js +0 -283
  891. package/src/components/table.js.map +0 -1
  892. package/src/components/table.schema.d.ts +0 -159
  893. package/src/components/table.schema.js +0 -173
  894. package/src/components/table.schema.js.map +0 -1
  895. package/src/handlebars/helpers.d.ts +0 -348
  896. package/src/handlebars/helpers.js +0 -605
  897. package/src/handlebars/helpers.js.map +0 -1
  898. package/src/handlebars/index.d.ts +0 -193
  899. package/src/handlebars/index.js +0 -350
  900. package/src/handlebars/index.js.map +0 -1
  901. package/src/index.d.ts +0 -50
  902. package/src/index.js +0 -192
  903. package/src/index.js.map +0 -1
  904. package/src/layouts/base.d.ts +0 -88
  905. package/src/layouts/base.js +0 -227
  906. package/src/layouts/base.js.map +0 -1
  907. package/src/layouts/index.d.ts +0 -7
  908. package/src/layouts/index.js +0 -25
  909. package/src/layouts/index.js.map +0 -1
  910. package/src/layouts/presets.d.ts +0 -133
  911. package/src/layouts/presets.js +0 -277
  912. package/src/layouts/presets.js.map +0 -1
  913. package/src/pages/consent.d.ts +0 -116
  914. package/src/pages/consent.js +0 -218
  915. package/src/pages/consent.js.map +0 -1
  916. package/src/pages/error.d.ts +0 -100
  917. package/src/pages/error.js +0 -263
  918. package/src/pages/error.js.map +0 -1
  919. package/src/pages/index.d.ts +0 -8
  920. package/src/pages/index.js +0 -27
  921. package/src/pages/index.js.map +0 -1
  922. package/src/react/Alert.d.ts +0 -101
  923. package/src/react/Alert.js +0 -51
  924. package/src/react/Alert.js.map +0 -1
  925. package/src/react/Badge.d.ts +0 -100
  926. package/src/react/Badge.js +0 -55
  927. package/src/react/Badge.js.map +0 -1
  928. package/src/react/Button.d.ts +0 -108
  929. package/src/react/Button.js +0 -52
  930. package/src/react/Button.js.map +0 -1
  931. package/src/react/Card.d.ts +0 -103
  932. package/src/react/Card.js +0 -55
  933. package/src/react/Card.js.map +0 -1
  934. package/src/react/hooks/context.d.ts +0 -178
  935. package/src/react/hooks/context.js +0 -287
  936. package/src/react/hooks/context.js.map +0 -1
  937. package/src/react/hooks/index.d.ts +0 -41
  938. package/src/react/hooks/index.js +0 -61
  939. package/src/react/hooks/index.js.map +0 -1
  940. package/src/react/hooks/tools.d.ts +0 -283
  941. package/src/react/hooks/tools.js +0 -465
  942. package/src/react/hooks/tools.js.map +0 -1
  943. package/src/react/index.d.ts +0 -80
  944. package/src/react/index.js +0 -113
  945. package/src/react/index.js.map +0 -1
  946. package/src/react/types.d.ts +0 -105
  947. package/src/react/types.js +0 -12
  948. package/src/react/types.js.map +0 -1
  949. package/src/react/utils.d.ts +0 -42
  950. package/src/react/utils.js +0 -99
  951. package/src/react/utils.js.map +0 -1
  952. package/src/registry/index.d.ts +0 -45
  953. package/src/registry/index.js +0 -67
  954. package/src/registry/index.js.map +0 -1
  955. package/src/registry/render-template.d.ts +0 -86
  956. package/src/registry/render-template.js +0 -239
  957. package/src/registry/render-template.js.map +0 -1
  958. package/src/registry/tool-ui.registry.d.ts +0 -260
  959. package/src/registry/tool-ui.registry.js +0 -438
  960. package/src/registry/tool-ui.registry.js.map +0 -1
  961. package/src/registry/uri-utils.d.ts +0 -55
  962. package/src/registry/uri-utils.js +0 -97
  963. package/src/registry/uri-utils.js.map +0 -1
  964. package/src/render/index.d.ts +0 -7
  965. package/src/render/index.js +0 -14
  966. package/src/render/index.js.map +0 -1
  967. package/src/render/prerender.d.ts +0 -56
  968. package/src/render/prerender.js +0 -98
  969. package/src/render/prerender.js.map +0 -1
  970. package/src/renderers/cache.d.ts +0 -144
  971. package/src/renderers/cache.js +0 -240
  972. package/src/renderers/cache.js.map +0 -1
  973. package/src/renderers/html.renderer.d.ts +0 -122
  974. package/src/renderers/html.renderer.js +0 -204
  975. package/src/renderers/html.renderer.js.map +0 -1
  976. package/src/renderers/index.d.ts +0 -35
  977. package/src/renderers/index.js +0 -70
  978. package/src/renderers/index.js.map +0 -1
  979. package/src/renderers/mdx.renderer.d.ts +0 -119
  980. package/src/renderers/mdx.renderer.js +0 -305
  981. package/src/renderers/mdx.renderer.js.map +0 -1
  982. package/src/renderers/react.renderer.d.ts +0 -95
  983. package/src/renderers/react.renderer.js +0 -260
  984. package/src/renderers/react.renderer.js.map +0 -1
  985. package/src/renderers/registry.d.ts +0 -133
  986. package/src/renderers/registry.js +0 -232
  987. package/src/renderers/registry.js.map +0 -1
  988. package/src/renderers/types.d.ts +0 -341
  989. package/src/renderers/types.js +0 -9
  990. package/src/renderers/types.js.map +0 -1
  991. package/src/renderers/utils/detect.d.ts +0 -106
  992. package/src/renderers/utils/detect.js +0 -267
  993. package/src/renderers/utils/detect.js.map +0 -1
  994. package/src/renderers/utils/hash.d.ts +0 -39
  995. package/src/renderers/utils/hash.js +0 -75
  996. package/src/renderers/utils/hash.js.map +0 -1
  997. package/src/renderers/utils/index.d.ts +0 -8
  998. package/src/renderers/utils/index.js +0 -28
  999. package/src/renderers/utils/index.js.map +0 -1
  1000. package/src/renderers/utils/transpiler.d.ts +0 -88
  1001. package/src/renderers/utils/transpiler.js +0 -215
  1002. package/src/renderers/utils/transpiler.js.map +0 -1
  1003. package/src/runtime/adapters/html.adapter.d.ts +0 -58
  1004. package/src/runtime/adapters/html.adapter.js +0 -131
  1005. package/src/runtime/adapters/html.adapter.js.map +0 -1
  1006. package/src/runtime/adapters/index.d.ts +0 -25
  1007. package/src/runtime/adapters/index.js +0 -54
  1008. package/src/runtime/adapters/index.js.map +0 -1
  1009. package/src/runtime/adapters/mdx.adapter.d.ts +0 -72
  1010. package/src/runtime/adapters/mdx.adapter.js +0 -241
  1011. package/src/runtime/adapters/mdx.adapter.js.map +0 -1
  1012. package/src/runtime/adapters/react.adapter.d.ts +0 -69
  1013. package/src/runtime/adapters/react.adapter.js +0 -245
  1014. package/src/runtime/adapters/react.adapter.js.map +0 -1
  1015. package/src/runtime/adapters/types.d.ts +0 -94
  1016. package/src/runtime/adapters/types.js +0 -11
  1017. package/src/runtime/adapters/types.js.map +0 -1
  1018. package/src/runtime/csp.d.ts +0 -37
  1019. package/src/runtime/csp.js +0 -140
  1020. package/src/runtime/csp.js.map +0 -1
  1021. package/src/runtime/index.d.ts +0 -16
  1022. package/src/runtime/index.js +0 -72
  1023. package/src/runtime/index.js.map +0 -1
  1024. package/src/runtime/mcp-bridge.d.ts +0 -100
  1025. package/src/runtime/mcp-bridge.js +0 -581
  1026. package/src/runtime/mcp-bridge.js.map +0 -1
  1027. package/src/runtime/renderer-runtime.d.ts +0 -132
  1028. package/src/runtime/renderer-runtime.js +0 -389
  1029. package/src/runtime/renderer-runtime.js.map +0 -1
  1030. package/src/runtime/sanitizer.d.ts +0 -171
  1031. package/src/runtime/sanitizer.js +0 -318
  1032. package/src/runtime/sanitizer.js.map +0 -1
  1033. package/src/runtime/types.d.ts +0 -414
  1034. package/src/runtime/types.js +0 -12
  1035. package/src/runtime/types.js.map +0 -1
  1036. package/src/runtime/wrapper.d.ts +0 -375
  1037. package/src/runtime/wrapper.js +0 -1793
  1038. package/src/runtime/wrapper.js.map +0 -1
  1039. package/src/styles/index.d.ts +0 -7
  1040. package/src/styles/index.js +0 -11
  1041. package/src/styles/index.js.map +0 -1
  1042. package/src/styles/variants.d.ts +0 -50
  1043. package/src/styles/variants.js +0 -175
  1044. package/src/styles/variants.js.map +0 -1
  1045. package/src/theme/cdn.d.ts +0 -194
  1046. package/src/theme/cdn.js +0 -375
  1047. package/src/theme/cdn.js.map +0 -1
  1048. package/src/theme/index.d.ts +0 -17
  1049. package/src/theme/index.js +0 -57
  1050. package/src/theme/index.js.map +0 -1
  1051. package/src/theme/platforms.d.ts +0 -106
  1052. package/src/theme/platforms.js +0 -161
  1053. package/src/theme/platforms.js.map +0 -1
  1054. package/src/theme/presets/github-openai.d.ts +0 -49
  1055. package/src/theme/presets/github-openai.js +0 -189
  1056. package/src/theme/presets/github-openai.js.map +0 -1
  1057. package/src/theme/presets/index.d.ts +0 -10
  1058. package/src/theme/presets/index.js +0 -17
  1059. package/src/theme/presets/index.js.map +0 -1
  1060. package/src/theme/theme.d.ts +0 -395
  1061. package/src/theme/theme.js +0 -332
  1062. package/src/theme/theme.js.map +0 -1
  1063. package/src/tool-template/builder.d.ts +0 -212
  1064. package/src/tool-template/builder.js +0 -397
  1065. package/src/tool-template/builder.js.map +0 -1
  1066. package/src/tool-template/index.d.ts +0 -15
  1067. package/src/tool-template/index.js +0 -38
  1068. package/src/tool-template/index.js.map +0 -1
  1069. package/src/types/index.d.ts +0 -13
  1070. package/src/types/index.js +0 -26
  1071. package/src/types/index.js.map +0 -1
  1072. package/src/types/ui-config.d.ts +0 -357
  1073. package/src/types/ui-config.js +0 -12
  1074. package/src/types/ui-config.js.map +0 -1
  1075. package/src/types/ui-runtime.d.ts +0 -965
  1076. package/src/types/ui-runtime.js +0 -117
  1077. package/src/types/ui-runtime.js.map +0 -1
  1078. package/src/validation/error-box.d.ts +0 -55
  1079. package/src/validation/error-box.js +0 -75
  1080. package/src/validation/error-box.js.map +0 -1
  1081. package/src/validation/index.d.ts +0 -12
  1082. package/src/validation/index.js +0 -21
  1083. package/src/validation/index.js.map +0 -1
  1084. package/src/validation/wrapper.d.ts +0 -96
  1085. package/src/validation/wrapper.js +0 -117
  1086. package/src/validation/wrapper.js.map +0 -1
  1087. package/src/web-components/core/attribute-parser.d.ts +0 -85
  1088. package/src/web-components/core/attribute-parser.js +0 -189
  1089. package/src/web-components/core/attribute-parser.js.map +0 -1
  1090. package/src/web-components/core/base-element.d.ts +0 -197
  1091. package/src/web-components/core/base-element.js +0 -289
  1092. package/src/web-components/core/base-element.js.map +0 -1
  1093. package/src/web-components/core/index.d.ts +0 -8
  1094. package/src/web-components/core/index.js +0 -18
  1095. package/src/web-components/core/index.js.map +0 -1
  1096. package/src/web-components/elements/fmcp-alert.d.ts +0 -45
  1097. package/src/web-components/elements/fmcp-alert.js +0 -93
  1098. package/src/web-components/elements/fmcp-alert.js.map +0 -1
  1099. package/src/web-components/elements/fmcp-badge.d.ts +0 -46
  1100. package/src/web-components/elements/fmcp-badge.js +0 -99
  1101. package/src/web-components/elements/fmcp-badge.js.map +0 -1
  1102. package/src/web-components/elements/fmcp-button.d.ts +0 -124
  1103. package/src/web-components/elements/fmcp-button.js +0 -233
  1104. package/src/web-components/elements/fmcp-button.js.map +0 -1
  1105. package/src/web-components/elements/fmcp-card.d.ts +0 -52
  1106. package/src/web-components/elements/fmcp-card.js +0 -115
  1107. package/src/web-components/elements/fmcp-card.js.map +0 -1
  1108. package/src/web-components/elements/fmcp-input.d.ts +0 -95
  1109. package/src/web-components/elements/fmcp-input.js +0 -248
  1110. package/src/web-components/elements/fmcp-input.js.map +0 -1
  1111. package/src/web-components/elements/fmcp-select.d.ts +0 -99
  1112. package/src/web-components/elements/fmcp-select.js +0 -243
  1113. package/src/web-components/elements/fmcp-select.js.map +0 -1
  1114. package/src/web-components/elements/index.d.ts +0 -12
  1115. package/src/web-components/elements/index.js +0 -34
  1116. package/src/web-components/elements/index.js.map +0 -1
  1117. package/src/web-components/index.d.ts +0 -49
  1118. package/src/web-components/index.js +0 -75
  1119. package/src/web-components/index.js.map +0 -1
  1120. package/src/web-components/register.d.ts +0 -56
  1121. package/src/web-components/register.js +0 -80
  1122. package/src/web-components/register.js.map +0 -1
  1123. package/src/web-components/types.d.ts +0 -121
  1124. package/src/web-components/types.js +0 -25
  1125. package/src/web-components/types.js.map +0 -1
  1126. package/src/widgets/index.d.ts +0 -7
  1127. package/src/widgets/index.js +0 -24
  1128. package/src/widgets/index.js.map +0 -1
  1129. package/src/widgets/progress.d.ts +0 -132
  1130. package/src/widgets/progress.js +0 -303
  1131. package/src/widgets/progress.js.map +0 -1
  1132. package/src/widgets/resource.d.ts +0 -162
  1133. package/src/widgets/resource.js +0 -340
  1134. package/src/widgets/resource.js.map +0 -1
@@ -0,0 +1,4754 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // libs/ui/src/bundler/file-cache/storage/interface.ts
34
+ function calculateManifestSize(manifest) {
35
+ try {
36
+ return Buffer.byteLength(JSON.stringify(manifest), "utf8");
37
+ } catch {
38
+ return 0;
39
+ }
40
+ }
41
+ var DEFAULT_STORAGE_OPTIONS;
42
+ var init_interface = __esm({
43
+ "libs/ui/src/bundler/file-cache/storage/interface.ts"() {
44
+ "use strict";
45
+ DEFAULT_STORAGE_OPTIONS = {
46
+ maxEntries: 1e3,
47
+ maxSize: 100 * 1024 * 1024,
48
+ // 100MB
49
+ defaultTtl: 24 * 60 * 60,
50
+ // 24 hours
51
+ compress: false
52
+ };
53
+ }
54
+ });
55
+
56
+ // libs/ui/src/bundler/file-cache/storage/filesystem.ts
57
+ var filesystem_exports = {};
58
+ __export(filesystem_exports, {
59
+ CacheInitializationError: () => CacheInitializationError,
60
+ CacheOperationError: () => CacheOperationError,
61
+ FilesystemStorage: () => FilesystemStorage,
62
+ StorageNotInitializedError: () => StorageNotInitializedError,
63
+ createFilesystemStorage: () => createFilesystemStorage
64
+ });
65
+ function createFilesystemStorage(options) {
66
+ return new FilesystemStorage(options);
67
+ }
68
+ var import_promises, import_path, import_fs, import_crypto, CacheInitializationError, CacheOperationError, StorageNotInitializedError, DEFAULT_FS_OPTIONS, FilesystemStorage;
69
+ var init_filesystem = __esm({
70
+ "libs/ui/src/bundler/file-cache/storage/filesystem.ts"() {
71
+ "use strict";
72
+ import_promises = require("fs/promises");
73
+ import_path = require("path");
74
+ import_fs = require("fs");
75
+ import_crypto = require("crypto");
76
+ init_interface();
77
+ CacheInitializationError = class extends Error {
78
+ cause;
79
+ constructor(message, cause) {
80
+ super(message);
81
+ this.name = "CacheInitializationError";
82
+ this.cause = cause;
83
+ }
84
+ };
85
+ CacheOperationError = class extends Error {
86
+ cause;
87
+ constructor(message, cause) {
88
+ super(message);
89
+ this.name = "CacheOperationError";
90
+ this.cause = cause;
91
+ }
92
+ };
93
+ StorageNotInitializedError = class extends Error {
94
+ constructor() {
95
+ super("Storage not initialized. Call initialize() first.");
96
+ this.name = "StorageNotInitializedError";
97
+ }
98
+ };
99
+ DEFAULT_FS_OPTIONS = {
100
+ ...DEFAULT_STORAGE_OPTIONS,
101
+ cacheDir: ".frontmcp-cache/builds",
102
+ extension: ".json"
103
+ };
104
+ FilesystemStorage = class {
105
+ type = "filesystem";
106
+ options;
107
+ initialized = false;
108
+ stats = {
109
+ entries: 0,
110
+ totalSize: 0,
111
+ hits: 0,
112
+ misses: 0,
113
+ hitRate: 0
114
+ };
115
+ constructor(options = {}) {
116
+ this.options = {
117
+ ...DEFAULT_FS_OPTIONS,
118
+ ...options
119
+ };
120
+ }
121
+ /**
122
+ * Initialize the storage directory.
123
+ */
124
+ async initialize() {
125
+ if (this.initialized) return;
126
+ try {
127
+ await (0, import_promises.mkdir)(this.options.cacheDir, { recursive: true });
128
+ await this.loadStats();
129
+ this.initialized = true;
130
+ } catch (error) {
131
+ throw new CacheInitializationError(`Failed to initialize cache directory: ${error}`, error);
132
+ }
133
+ }
134
+ /**
135
+ * Get a cached manifest.
136
+ */
137
+ async get(key) {
138
+ this.ensureInitialized();
139
+ const filePath = this.getFilePath(key);
140
+ try {
141
+ if (!(0, import_fs.existsSync)(filePath)) {
142
+ this.stats.misses++;
143
+ this.updateHitRate();
144
+ return void 0;
145
+ }
146
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
147
+ const entry = JSON.parse(content);
148
+ if (Date.now() > entry.metadata.expiresAt) {
149
+ await this.delete(key);
150
+ this.stats.misses++;
151
+ this.updateHitRate();
152
+ return void 0;
153
+ }
154
+ entry.metadata.lastAccessedAt = Date.now();
155
+ entry.metadata.accessCount++;
156
+ this.writeEntry(filePath, entry).catch((err) => {
157
+ if (process.env["DEBUG"]) {
158
+ console.debug(`[FilesystemStorage] Failed to update cache metadata for ${key}: ${err}`);
159
+ }
160
+ });
161
+ this.stats.hits++;
162
+ this.updateHitRate();
163
+ return entry.data;
164
+ } catch {
165
+ this.stats.misses++;
166
+ this.updateHitRate();
167
+ return void 0;
168
+ }
169
+ }
170
+ /**
171
+ * Store a manifest in cache.
172
+ */
173
+ async set(key, manifest, ttl) {
174
+ this.ensureInitialized();
175
+ const filePath = this.getFilePath(key);
176
+ const size = calculateManifestSize(manifest);
177
+ const effectiveTtl = ttl ?? this.options.defaultTtl;
178
+ await this.ensureCapacity(size);
179
+ const entry = {
180
+ data: manifest,
181
+ metadata: {
182
+ key,
183
+ size,
184
+ createdAt: Date.now(),
185
+ expiresAt: Date.now() + effectiveTtl * 1e3,
186
+ lastAccessedAt: Date.now(),
187
+ accessCount: 0
188
+ }
189
+ };
190
+ await this.writeEntry(filePath, entry);
191
+ this.stats.entries++;
192
+ this.stats.totalSize += size;
193
+ }
194
+ /**
195
+ * Check if a key exists.
196
+ */
197
+ async has(key) {
198
+ this.ensureInitialized();
199
+ const filePath = this.getFilePath(key);
200
+ try {
201
+ if (!(0, import_fs.existsSync)(filePath)) return false;
202
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
203
+ const entry = JSON.parse(content);
204
+ if (Date.now() > entry.metadata.expiresAt) {
205
+ await this.delete(key);
206
+ return false;
207
+ }
208
+ return true;
209
+ } catch {
210
+ return false;
211
+ }
212
+ }
213
+ /**
214
+ * Delete a cached entry.
215
+ */
216
+ async delete(key) {
217
+ this.ensureInitialized();
218
+ const filePath = this.getFilePath(key);
219
+ try {
220
+ if (!(0, import_fs.existsSync)(filePath)) return false;
221
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
222
+ const entry = JSON.parse(content);
223
+ await (0, import_promises.unlink)(filePath);
224
+ this.stats.entries = Math.max(0, this.stats.entries - 1);
225
+ this.stats.totalSize = Math.max(0, this.stats.totalSize - entry.metadata.size);
226
+ return true;
227
+ } catch {
228
+ return false;
229
+ }
230
+ }
231
+ /**
232
+ * Clear all cached entries.
233
+ */
234
+ async clear() {
235
+ this.ensureInitialized();
236
+ try {
237
+ await (0, import_promises.rm)(this.options.cacheDir, { recursive: true, force: true });
238
+ await (0, import_promises.mkdir)(this.options.cacheDir, { recursive: true });
239
+ this.stats = {
240
+ entries: 0,
241
+ totalSize: 0,
242
+ hits: 0,
243
+ misses: 0,
244
+ hitRate: 0
245
+ };
246
+ } catch (error) {
247
+ throw new CacheOperationError(`Failed to clear cache: ${error}`, error);
248
+ }
249
+ }
250
+ /**
251
+ * Get cache statistics.
252
+ */
253
+ async getStats() {
254
+ return { ...this.stats };
255
+ }
256
+ /**
257
+ * Clean up expired entries.
258
+ */
259
+ async cleanup() {
260
+ this.ensureInitialized();
261
+ let removed = 0;
262
+ try {
263
+ const files = await (0, import_promises.readdir)(this.options.cacheDir);
264
+ for (const file of files) {
265
+ if (!file.endsWith(this.options.extension)) continue;
266
+ const filePath = (0, import_path.join)(this.options.cacheDir, file);
267
+ try {
268
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
269
+ const entry = JSON.parse(content);
270
+ if (Date.now() > entry.metadata.expiresAt) {
271
+ await (0, import_promises.unlink)(filePath);
272
+ this.stats.entries = Math.max(0, this.stats.entries - 1);
273
+ this.stats.totalSize = Math.max(0, this.stats.totalSize - entry.metadata.size);
274
+ removed++;
275
+ }
276
+ } catch {
277
+ await (0, import_promises.unlink)(filePath).catch(() => {
278
+ });
279
+ removed++;
280
+ }
281
+ }
282
+ } catch {
283
+ }
284
+ return removed;
285
+ }
286
+ /**
287
+ * Close the storage (no-op for filesystem).
288
+ */
289
+ async close() {
290
+ }
291
+ /**
292
+ * Get the file path for a cache key.
293
+ * Uses SHA-256 hash to avoid collisions from key sanitization.
294
+ */
295
+ getFilePath(key) {
296
+ const hash = (0, import_crypto.createHash)("sha256").update(key).digest("hex").slice(0, 16);
297
+ return (0, import_path.join)(this.options.cacheDir, `${hash}${this.options.extension}`);
298
+ }
299
+ /**
300
+ * Write a cache entry to disk.
301
+ */
302
+ async writeEntry(filePath, entry) {
303
+ await (0, import_promises.mkdir)((0, import_path.dirname)(filePath), { recursive: true });
304
+ await (0, import_promises.writeFile)(filePath, JSON.stringify(entry, null, 2), "utf8");
305
+ }
306
+ /**
307
+ * Ensure the storage is initialized.
308
+ */
309
+ ensureInitialized() {
310
+ if (!this.initialized) {
311
+ throw new StorageNotInitializedError();
312
+ }
313
+ }
314
+ /**
315
+ * Load stats from existing cache files.
316
+ * Reads entry metadata to get accurate manifest sizes.
317
+ */
318
+ async loadStats() {
319
+ try {
320
+ const files = await (0, import_promises.readdir)(this.options.cacheDir);
321
+ let entries = 0;
322
+ let totalSize = 0;
323
+ for (const file of files) {
324
+ if (!file.endsWith(this.options.extension)) continue;
325
+ const filePath = (0, import_path.join)(this.options.cacheDir, file);
326
+ try {
327
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
328
+ const entry = JSON.parse(content);
329
+ entries++;
330
+ totalSize += entry.metadata.size;
331
+ } catch {
332
+ }
333
+ }
334
+ this.stats.entries = entries;
335
+ this.stats.totalSize = totalSize;
336
+ } catch {
337
+ }
338
+ }
339
+ /**
340
+ * Ensure there's capacity for a new entry.
341
+ */
342
+ async ensureCapacity(newEntrySize) {
343
+ if (this.stats.entries >= this.options.maxEntries) {
344
+ await this.evictLRU();
345
+ }
346
+ while (this.stats.totalSize + newEntrySize > this.options.maxSize) {
347
+ const evicted = await this.evictLRU();
348
+ if (!evicted) break;
349
+ }
350
+ }
351
+ /**
352
+ * Evict the least recently used entry.
353
+ */
354
+ async evictLRU() {
355
+ try {
356
+ const files = await (0, import_promises.readdir)(this.options.cacheDir);
357
+ let oldestKey = null;
358
+ let oldestTime = Infinity;
359
+ let corruptedFile = null;
360
+ for (const file of files) {
361
+ if (!file.endsWith(this.options.extension)) continue;
362
+ const filePath = (0, import_path.join)(this.options.cacheDir, file);
363
+ try {
364
+ const content = await (0, import_promises.readFile)(filePath, "utf8");
365
+ const entry = JSON.parse(content);
366
+ if (entry.metadata.lastAccessedAt < oldestTime) {
367
+ oldestTime = entry.metadata.lastAccessedAt;
368
+ oldestKey = entry.metadata.key;
369
+ }
370
+ } catch {
371
+ corruptedFile = filePath;
372
+ }
373
+ }
374
+ if (corruptedFile) {
375
+ try {
376
+ await (0, import_promises.unlink)(corruptedFile);
377
+ this.stats.entries = Math.max(0, this.stats.entries - 1);
378
+ return true;
379
+ } catch {
380
+ return false;
381
+ }
382
+ }
383
+ if (oldestKey) {
384
+ return await this.delete(oldestKey);
385
+ }
386
+ return false;
387
+ } catch {
388
+ return false;
389
+ }
390
+ }
391
+ /**
392
+ * Update hit rate statistic.
393
+ */
394
+ updateHitRate() {
395
+ const total = this.stats.hits + this.stats.misses;
396
+ this.stats.hitRate = total > 0 ? this.stats.hits / total : 0;
397
+ }
398
+ };
399
+ }
400
+ });
401
+
402
+ // libs/ui/src/bundler/file-cache/storage/redis.ts
403
+ var redis_exports = {};
404
+ __export(redis_exports, {
405
+ RedisStorage: () => RedisStorage,
406
+ createRedisStorage: () => createRedisStorage
407
+ });
408
+ function createRedisStorage(options) {
409
+ return new RedisStorage(options);
410
+ }
411
+ var STATS_KEY_SUFFIX, RedisStorage;
412
+ var init_redis = __esm({
413
+ "libs/ui/src/bundler/file-cache/storage/redis.ts"() {
414
+ "use strict";
415
+ init_interface();
416
+ STATS_KEY_SUFFIX = ":__stats__";
417
+ RedisStorage = class {
418
+ type = "redis";
419
+ options;
420
+ initialized = false;
421
+ localStats = {
422
+ entries: 0,
423
+ totalSize: 0,
424
+ hits: 0,
425
+ misses: 0,
426
+ hitRate: 0
427
+ };
428
+ constructor(options) {
429
+ if (!options.client) {
430
+ throw new Error("Redis client is required");
431
+ }
432
+ this.options = {
433
+ ...DEFAULT_STORAGE_OPTIONS,
434
+ keyPrefix: "frontmcp:ui:build:",
435
+ json: true,
436
+ ...options
437
+ };
438
+ }
439
+ /**
440
+ * Initialize the Redis connection.
441
+ */
442
+ async initialize() {
443
+ if (this.initialized) return;
444
+ try {
445
+ await this.options.client.ping();
446
+ await this.loadStats();
447
+ this.initialized = true;
448
+ } catch (error) {
449
+ throw new Error(`Failed to connect to Redis: ${error}`);
450
+ }
451
+ }
452
+ /**
453
+ * Get a cached manifest.
454
+ */
455
+ async get(key) {
456
+ this.ensureInitialized();
457
+ const redisKey = this.getRedisKey(key);
458
+ try {
459
+ const data = await this.options.client.get(redisKey);
460
+ if (!data) {
461
+ this.localStats.misses++;
462
+ this.updateHitRate();
463
+ await this.persistStats();
464
+ return void 0;
465
+ }
466
+ const entry = JSON.parse(data);
467
+ entry.metadata.lastAccessedAt = Date.now();
468
+ entry.metadata.accessCount++;
469
+ const ttl = await this.options.client.ttl(redisKey);
470
+ if (ttl > 0) {
471
+ const serialized = JSON.stringify(entry);
472
+ await this.options.client.setex(redisKey, ttl, serialized);
473
+ }
474
+ this.localStats.hits++;
475
+ this.updateHitRate();
476
+ await this.persistStats();
477
+ return entry.data;
478
+ } catch (error) {
479
+ console.warn?.(`Redis cache get failed for key "${key}": ${error}`);
480
+ this.localStats.misses++;
481
+ this.updateHitRate();
482
+ await this.persistStats().catch(() => {
483
+ });
484
+ return void 0;
485
+ }
486
+ }
487
+ /**
488
+ * Store a manifest in cache.
489
+ */
490
+ async set(key, manifest, ttl) {
491
+ this.ensureInitialized();
492
+ const redisKey = this.getRedisKey(key);
493
+ const size = calculateManifestSize(manifest);
494
+ const effectiveTtl = ttl ?? this.options.defaultTtl;
495
+ const entry = {
496
+ data: manifest,
497
+ metadata: {
498
+ key,
499
+ size,
500
+ createdAt: Date.now(),
501
+ expiresAt: Date.now() + effectiveTtl * 1e3,
502
+ lastAccessedAt: Date.now(),
503
+ accessCount: 0
504
+ }
505
+ };
506
+ const serialized = JSON.stringify(entry);
507
+ await this.options.client.setex(redisKey, effectiveTtl, serialized);
508
+ this.localStats.entries++;
509
+ this.localStats.totalSize += size;
510
+ await this.persistStats();
511
+ }
512
+ /**
513
+ * Check if a key exists.
514
+ */
515
+ async has(key) {
516
+ this.ensureInitialized();
517
+ const redisKey = this.getRedisKey(key);
518
+ const exists = await this.options.client.exists(redisKey);
519
+ return exists > 0;
520
+ }
521
+ /**
522
+ * Delete a cached entry.
523
+ */
524
+ async delete(key) {
525
+ this.ensureInitialized();
526
+ const redisKey = this.getRedisKey(key);
527
+ try {
528
+ const data = await this.options.client.get(redisKey);
529
+ if (data) {
530
+ const entry = JSON.parse(data);
531
+ this.localStats.totalSize = Math.max(0, this.localStats.totalSize - entry.metadata.size);
532
+ }
533
+ } catch {
534
+ }
535
+ const deleted = await this.options.client.del(redisKey);
536
+ if (deleted > 0) {
537
+ this.localStats.entries = Math.max(0, this.localStats.entries - 1);
538
+ await this.persistStats();
539
+ return true;
540
+ }
541
+ return false;
542
+ }
543
+ /**
544
+ * Clear all cached entries.
545
+ */
546
+ async clear() {
547
+ this.ensureInitialized();
548
+ const pattern = `${this.options.keyPrefix}*`;
549
+ const keys = await this.options.client.keys(pattern);
550
+ if (keys.length > 0) {
551
+ await this.options.client.del(keys);
552
+ }
553
+ this.localStats = {
554
+ entries: 0,
555
+ totalSize: 0,
556
+ hits: 0,
557
+ misses: 0,
558
+ hitRate: 0
559
+ };
560
+ await this.persistStats();
561
+ }
562
+ /**
563
+ * Get cache statistics.
564
+ */
565
+ async getStats() {
566
+ await this.loadStats();
567
+ return { ...this.localStats };
568
+ }
569
+ /**
570
+ * Clean up expired entries.
571
+ * Redis handles TTL expiration automatically, so this just refreshes stats.
572
+ */
573
+ async cleanup() {
574
+ this.ensureInitialized();
575
+ const pattern = `${this.options.keyPrefix}*`;
576
+ const keys = await this.options.client.keys(pattern);
577
+ const dataKeys = keys.filter((k) => !k.endsWith(STATS_KEY_SUFFIX));
578
+ const previousCount = this.localStats.entries;
579
+ this.localStats.entries = dataKeys.length;
580
+ let totalSize = 0;
581
+ for (const key of dataKeys) {
582
+ try {
583
+ const data = await this.options.client.get(key);
584
+ if (data) {
585
+ const entry = JSON.parse(data);
586
+ totalSize += entry.metadata.size;
587
+ }
588
+ } catch {
589
+ }
590
+ }
591
+ this.localStats.totalSize = totalSize;
592
+ await this.persistStats();
593
+ return Math.max(0, previousCount - this.localStats.entries);
594
+ }
595
+ /**
596
+ * Close the Redis connection.
597
+ */
598
+ async close() {
599
+ await this.options.client.quit();
600
+ }
601
+ /**
602
+ * Get the Redis key for a cache key.
603
+ */
604
+ getRedisKey(key) {
605
+ return `${this.options.keyPrefix}${key}`;
606
+ }
607
+ /**
608
+ * Get the Redis key for stats.
609
+ */
610
+ getStatsKey() {
611
+ return `${this.options.keyPrefix}${STATS_KEY_SUFFIX}`;
612
+ }
613
+ /**
614
+ * Ensure the storage is initialized.
615
+ */
616
+ ensureInitialized() {
617
+ if (!this.initialized) {
618
+ throw new Error("Storage not initialized. Call initialize() first.");
619
+ }
620
+ }
621
+ /**
622
+ * Load stats from Redis.
623
+ */
624
+ async loadStats() {
625
+ try {
626
+ const statsKey = this.getStatsKey();
627
+ const data = await this.options.client.get(statsKey);
628
+ if (data) {
629
+ const savedStats = JSON.parse(data);
630
+ this.localStats = {
631
+ ...this.localStats,
632
+ ...savedStats
633
+ };
634
+ }
635
+ } catch {
636
+ }
637
+ }
638
+ /**
639
+ * Persist stats to Redis.
640
+ */
641
+ async persistStats() {
642
+ try {
643
+ const statsKey = this.getStatsKey();
644
+ const serialized = JSON.stringify(this.localStats);
645
+ await this.options.client.set(statsKey, serialized);
646
+ } catch {
647
+ }
648
+ }
649
+ /**
650
+ * Update hit rate statistic.
651
+ */
652
+ updateHitRate() {
653
+ const total = this.localStats.hits + this.localStats.misses;
654
+ this.localStats.hitRate = total > 0 ? this.localStats.hits / total : 0;
655
+ }
656
+ };
657
+ }
658
+ });
659
+
660
+ // libs/ui/src/bundler/index.ts
661
+ var bundler_exports = {};
662
+ __export(bundler_exports, {
663
+ BundlerCache: () => BundlerCache,
664
+ ComponentBuilder: () => ComponentBuilder,
665
+ DEFAULT_BUNDLER_OPTIONS: () => DEFAULT_BUNDLER_OPTIONS,
666
+ DEFAULT_BUNDLE_OPTIONS: () => DEFAULT_BUNDLE_OPTIONS,
667
+ DEFAULT_SECURITY_POLICY: () => DEFAULT_SECURITY_POLICY,
668
+ DEFAULT_STATIC_HTML_OPTIONS: () => DEFAULT_STATIC_HTML_OPTIONS,
669
+ DEFAULT_STORAGE_OPTIONS: () => DEFAULT_STORAGE_OPTIONS,
670
+ ExecutionError: () => ExecutionError,
671
+ FilesystemStorage: () => FilesystemStorage,
672
+ InMemoryBundler: () => InMemoryBundler,
673
+ RedisStorage: () => RedisStorage,
674
+ STATIC_HTML_CDN: () => STATIC_HTML_CDN,
675
+ SecurityError: () => SecurityError,
676
+ buildIdFromHash: () => buildIdFromHash,
677
+ calculateComponentHash: () => calculateComponentHash,
678
+ calculateManifestSize: () => calculateManifestSize,
679
+ calculateQuickHash: () => calculateQuickHash,
680
+ createBundler: () => createBundler,
681
+ createCacheKey: () => createCacheKey,
682
+ createFilesystemBuilder: () => createFilesystemBuilder,
683
+ createFilesystemStorage: () => createFilesystemStorage,
684
+ createRedisBuilder: () => createRedisBuilder,
685
+ createRedisStorage: () => createRedisStorage,
686
+ executeCode: () => executeCode,
687
+ executeDefault: () => executeDefault,
688
+ generateBuildId: () => generateBuildId,
689
+ getCdnTypeForPlatform: () => getCdnTypeForPlatform,
690
+ hashContent: () => hashContent,
691
+ hashFile: () => hashFile,
692
+ hashFiles: () => hashFiles,
693
+ isExecutionError: () => isExecutionError,
694
+ mergePolicy: () => mergePolicy,
695
+ sha256: () => sha256,
696
+ sha256Buffer: () => sha256Buffer,
697
+ throwOnViolations: () => throwOnViolations,
698
+ validateImports: () => validateImports,
699
+ validateSize: () => validateSize,
700
+ validateSource: () => validateSource
701
+ });
702
+ module.exports = __toCommonJS(bundler_exports);
703
+
704
+ // libs/ui/src/bundler/types.ts
705
+ var DEFAULT_SECURITY_POLICY = {
706
+ allowedImports: [/^react$/, /^react-dom$/, /^react\/jsx-runtime$/, /^react\/jsx-dev-runtime$/, /^@frontmcp\/ui/],
707
+ blockedImports: [
708
+ /^fs$/,
709
+ /^fs\//,
710
+ /^net$/,
711
+ /^child_process$/,
712
+ /^os$/,
713
+ /^path$/,
714
+ /^crypto$/,
715
+ /^http$/,
716
+ /^https$/,
717
+ /^dgram$/,
718
+ /^dns$/,
719
+ /^cluster$/,
720
+ /^readline$/,
721
+ /^repl$/,
722
+ /^tls$/,
723
+ /^vm$/,
724
+ /^worker_threads$/
725
+ ],
726
+ maxBundleSize: 512e3,
727
+ // 500KB
728
+ maxTransformTime: 5e3,
729
+ // 5s
730
+ noEval: true,
731
+ noDynamicImports: true,
732
+ noRequire: true,
733
+ allowedGlobals: [
734
+ "console",
735
+ "Math",
736
+ "JSON",
737
+ "Date",
738
+ "Array",
739
+ "Object",
740
+ "String",
741
+ "Number",
742
+ "Boolean",
743
+ "Promise",
744
+ "Map",
745
+ "Set",
746
+ "WeakMap",
747
+ "WeakSet",
748
+ "Symbol",
749
+ "Reflect",
750
+ "Proxy",
751
+ "Error",
752
+ "TypeError",
753
+ "RangeError",
754
+ "SyntaxError",
755
+ "ReferenceError",
756
+ "parseInt",
757
+ "parseFloat",
758
+ "isNaN",
759
+ "isFinite",
760
+ "encodeURI",
761
+ "encodeURIComponent",
762
+ "decodeURI",
763
+ "decodeURIComponent",
764
+ "setTimeout",
765
+ "clearTimeout",
766
+ "setInterval",
767
+ "clearInterval",
768
+ "atob",
769
+ "btoa",
770
+ "Intl",
771
+ "TextEncoder",
772
+ "TextDecoder",
773
+ "URL",
774
+ "URLSearchParams",
775
+ "Uint8Array",
776
+ "Int8Array",
777
+ "Uint16Array",
778
+ "Int16Array",
779
+ "Uint32Array",
780
+ "Int32Array",
781
+ "Float32Array",
782
+ "Float64Array",
783
+ "BigInt",
784
+ "BigInt64Array",
785
+ "BigUint64Array",
786
+ "ArrayBuffer",
787
+ "SharedArrayBuffer",
788
+ "DataView",
789
+ "queueMicrotask"
790
+ ]
791
+ };
792
+ var DEFAULT_BUNDLE_OPTIONS = {
793
+ sourceType: "auto",
794
+ format: "iife",
795
+ minify: false,
796
+ sourceMaps: false,
797
+ externals: ["react", "react-dom"],
798
+ jsx: {
799
+ runtime: "automatic",
800
+ importSource: "react"
801
+ },
802
+ target: "es2020",
803
+ globalName: "Widget",
804
+ skipCache: false
805
+ };
806
+ var DEFAULT_BUNDLER_OPTIONS = {
807
+ defaultSecurity: DEFAULT_SECURITY_POLICY,
808
+ cache: {
809
+ maxSize: 100,
810
+ ttl: 3e5,
811
+ // 5 minutes
812
+ disabled: false
813
+ },
814
+ verbose: false,
815
+ esbuildOptions: {}
816
+ };
817
+ var STATIC_HTML_CDN = {
818
+ /**
819
+ * ES modules from esm.sh (React 19, modern platforms)
820
+ */
821
+ esm: {
822
+ react: "https://esm.sh/react@19",
823
+ reactDom: "https://esm.sh/react-dom@19/client"
824
+ },
825
+ /**
826
+ * UMD builds from cdnjs (React 18.2, Claude only trusts cloudflare)
827
+ */
828
+ umd: {
829
+ react: "https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js",
830
+ reactDom: "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"
831
+ },
832
+ /**
833
+ * Tailwind CSS from cdnjs (cloudflare) - works on all platforms
834
+ * Using CSS file instead of JS browser version to avoid style normalization issues
835
+ */
836
+ tailwind: "https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/3.4.1/tailwind.min.css",
837
+ /**
838
+ * Font CDN URLs
839
+ */
840
+ fonts: {
841
+ preconnect: ["https://fonts.googleapis.com", "https://fonts.gstatic.com"],
842
+ inter: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
843
+ }
844
+ };
845
+ function getCdnTypeForPlatform(platform) {
846
+ if (platform === "claude") return "umd";
847
+ return "esm";
848
+ }
849
+ var DEFAULT_STATIC_HTML_OPTIONS = {
850
+ sourceType: "auto",
851
+ targetPlatform: "auto",
852
+ minify: true,
853
+ skipCache: false,
854
+ rootId: "frontmcp-widget-root",
855
+ widgetAccessible: false,
856
+ externals: {
857
+ react: "cdn",
858
+ reactDom: "cdn",
859
+ tailwind: "cdn",
860
+ frontmcpUi: "inline"
861
+ },
862
+ // Universal mode defaults
863
+ universal: false,
864
+ contentType: "auto",
865
+ includeMarkdown: false,
866
+ includeMdx: false
867
+ };
868
+
869
+ // libs/ui/src/bundler/cache.ts
870
+ var BundlerCache = class {
871
+ cache = /* @__PURE__ */ new Map();
872
+ options;
873
+ stats = {
874
+ hits: 0,
875
+ misses: 0,
876
+ evictions: 0
877
+ };
878
+ constructor(options = {}) {
879
+ this.options = {
880
+ maxSize: options.maxSize ?? 100,
881
+ ttl: options.ttl ?? 3e5
882
+ };
883
+ }
884
+ /**
885
+ * Get a cached bundle result.
886
+ *
887
+ * @param key - Cache key (typically content hash)
888
+ * @returns Cached result or undefined if not found/expired
889
+ */
890
+ get(key) {
891
+ const entry = this.cache.get(key);
892
+ if (!entry) {
893
+ this.stats.misses++;
894
+ return void 0;
895
+ }
896
+ if (this.isExpired(entry)) {
897
+ this.cache.delete(key);
898
+ this.stats.misses++;
899
+ this.stats.evictions++;
900
+ return void 0;
901
+ }
902
+ entry.lastAccessedAt = Date.now();
903
+ entry.accessCount++;
904
+ this.stats.hits++;
905
+ this.cache.delete(key);
906
+ this.cache.set(key, entry);
907
+ return entry.result;
908
+ }
909
+ /**
910
+ * Store a bundle result in the cache.
911
+ *
912
+ * @param key - Cache key (typically content hash)
913
+ * @param result - Bundle result to cache
914
+ */
915
+ set(key, result) {
916
+ while (this.cache.size >= this.options.maxSize) {
917
+ this.evictOldest();
918
+ }
919
+ const now = Date.now();
920
+ const entry = {
921
+ result,
922
+ createdAt: now,
923
+ lastAccessedAt: now,
924
+ accessCount: 1
925
+ };
926
+ this.cache.set(key, entry);
927
+ }
928
+ /**
929
+ * Check if a key exists in the cache (and is not expired).
930
+ *
931
+ * @param key - Cache key to check
932
+ * @returns true if key exists and is not expired
933
+ */
934
+ has(key) {
935
+ const entry = this.cache.get(key);
936
+ if (!entry) return false;
937
+ if (this.isExpired(entry)) {
938
+ this.cache.delete(key);
939
+ this.stats.evictions++;
940
+ return false;
941
+ }
942
+ return true;
943
+ }
944
+ /**
945
+ * Delete a specific entry from the cache.
946
+ *
947
+ * @param key - Cache key to delete
948
+ * @returns true if the key was found and deleted
949
+ */
950
+ delete(key) {
951
+ return this.cache.delete(key);
952
+ }
953
+ /**
954
+ * Clear all entries from the cache.
955
+ */
956
+ clear() {
957
+ this.cache.clear();
958
+ this.stats = {
959
+ hits: 0,
960
+ misses: 0,
961
+ evictions: 0
962
+ };
963
+ }
964
+ /**
965
+ * Get cache statistics.
966
+ *
967
+ * @returns Current cache statistics
968
+ */
969
+ getStats() {
970
+ const total = this.stats.hits + this.stats.misses;
971
+ const hitRate = total > 0 ? this.stats.hits / total : 0;
972
+ let memoryUsage = 0;
973
+ for (const entry of this.cache.values()) {
974
+ memoryUsage += entry.result.size;
975
+ if (entry.result.map) {
976
+ memoryUsage += entry.result.map.length;
977
+ }
978
+ }
979
+ return {
980
+ size: this.cache.size,
981
+ hits: this.stats.hits,
982
+ misses: this.stats.misses,
983
+ hitRate,
984
+ evictions: this.stats.evictions,
985
+ memoryUsage
986
+ };
987
+ }
988
+ /**
989
+ * Remove expired entries from the cache.
990
+ *
991
+ * @returns Number of entries removed
992
+ */
993
+ cleanup() {
994
+ let removed = 0;
995
+ for (const [key, entry] of this.cache.entries()) {
996
+ if (this.isExpired(entry)) {
997
+ this.cache.delete(key);
998
+ removed++;
999
+ }
1000
+ }
1001
+ this.stats.evictions += removed;
1002
+ return removed;
1003
+ }
1004
+ /**
1005
+ * Get all cache keys.
1006
+ *
1007
+ * @returns Array of cache keys
1008
+ */
1009
+ keys() {
1010
+ return Array.from(this.cache.keys());
1011
+ }
1012
+ /**
1013
+ * Get the number of entries in the cache.
1014
+ */
1015
+ get size() {
1016
+ return this.cache.size;
1017
+ }
1018
+ /**
1019
+ * Check if an entry is expired.
1020
+ */
1021
+ isExpired(entry) {
1022
+ return Date.now() - entry.createdAt > this.options.ttl;
1023
+ }
1024
+ /**
1025
+ * Evict the oldest (least recently used) entry.
1026
+ */
1027
+ evictOldest() {
1028
+ const oldestKey = this.cache.keys().next().value;
1029
+ if (oldestKey !== void 0) {
1030
+ this.cache.delete(oldestKey);
1031
+ this.stats.evictions++;
1032
+ }
1033
+ }
1034
+ };
1035
+ function hashContent(content) {
1036
+ let hash = 2166136261;
1037
+ for (let i = 0; i < content.length; i++) {
1038
+ hash ^= content.charCodeAt(i);
1039
+ hash = Math.imul(hash, 16777619);
1040
+ }
1041
+ return (hash >>> 0).toString(16).padStart(8, "0");
1042
+ }
1043
+ function createCacheKey(source, options) {
1044
+ const sourceHash = hashContent(source);
1045
+ const optionsHash = hashContent(
1046
+ JSON.stringify({
1047
+ sourceType: options.sourceType,
1048
+ format: options.format,
1049
+ minify: options.minify,
1050
+ externals: options.externals?.sort(),
1051
+ target: options.target
1052
+ })
1053
+ );
1054
+ return `${sourceHash}-${optionsHash}`;
1055
+ }
1056
+
1057
+ // libs/ui/src/bundler/sandbox/policy.ts
1058
+ var UNSAFE_PATTERNS = {
1059
+ eval: /\beval\s*\(/g,
1060
+ functionConstructor: /\bnew\s+Function\s*\(/g,
1061
+ dynamicImport: /\bimport\s*\(/g,
1062
+ require: /\brequire\s*\(/g,
1063
+ processEnv: /\bprocess\.env\b/g,
1064
+ globalThis: /\bglobalThis\b/g,
1065
+ windowLocation: /\bwindow\.location\b/g,
1066
+ documentCookie: /\bdocument\.cookie\b/g,
1067
+ innerHTML: /\.innerHTML\s*=/g,
1068
+ outerHTML: /\.outerHTML\s*=/g,
1069
+ document_write: /\bdocument\.write\s*\(/g
1070
+ };
1071
+ function validateSource(source, policy = DEFAULT_SECURITY_POLICY) {
1072
+ const violations = [];
1073
+ if (policy.noEval !== false) {
1074
+ const evalMatches = [...source.matchAll(UNSAFE_PATTERNS.eval)];
1075
+ for (const match of evalMatches) {
1076
+ violations.push({
1077
+ type: "eval-usage",
1078
+ message: "eval() is not allowed for security reasons",
1079
+ location: getLocation(source, match.index ?? 0),
1080
+ value: match[0]
1081
+ });
1082
+ }
1083
+ const fnMatches = [...source.matchAll(UNSAFE_PATTERNS.functionConstructor)];
1084
+ for (const match of fnMatches) {
1085
+ violations.push({
1086
+ type: "eval-usage",
1087
+ message: "new Function() is not allowed for security reasons",
1088
+ location: getLocation(source, match.index ?? 0),
1089
+ value: match[0]
1090
+ });
1091
+ }
1092
+ }
1093
+ if (policy.noDynamicImports !== false) {
1094
+ const matches = [...source.matchAll(UNSAFE_PATTERNS.dynamicImport)];
1095
+ for (const match of matches) {
1096
+ violations.push({
1097
+ type: "dynamic-import",
1098
+ message: "Dynamic imports are not allowed for security reasons",
1099
+ location: getLocation(source, match.index ?? 0),
1100
+ value: match[0]
1101
+ });
1102
+ }
1103
+ }
1104
+ if (policy.noRequire !== false) {
1105
+ const matches = [...source.matchAll(UNSAFE_PATTERNS.require)];
1106
+ for (const match of matches) {
1107
+ violations.push({
1108
+ type: "require-usage",
1109
+ message: "require() is not allowed for security reasons",
1110
+ location: getLocation(source, match.index ?? 0),
1111
+ value: match[0]
1112
+ });
1113
+ }
1114
+ }
1115
+ const importViolations = validateImports(source, policy);
1116
+ violations.push(...importViolations);
1117
+ return violations;
1118
+ }
1119
+ function validateImports(source, policy = DEFAULT_SECURITY_POLICY) {
1120
+ const violations = [];
1121
+ const importPattern = /import\s+(?:(?:\{[^}]*\}|[\w*]+)\s+from\s+)?['"]([^'"]+)['"]/g;
1122
+ const imports = [];
1123
+ let match;
1124
+ while ((match = importPattern.exec(source)) !== null) {
1125
+ imports.push({ module: match[1], index: match.index });
1126
+ }
1127
+ const requirePattern = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
1128
+ while ((match = requirePattern.exec(source)) !== null) {
1129
+ imports.push({ module: match[1], index: match.index });
1130
+ }
1131
+ for (const imp of imports) {
1132
+ if (policy.blockedImports) {
1133
+ for (const blocked of policy.blockedImports) {
1134
+ if (blocked.test(imp.module)) {
1135
+ violations.push({
1136
+ type: "blocked-import",
1137
+ message: `Import '${imp.module}' is blocked by security policy`,
1138
+ location: getLocation(source, imp.index),
1139
+ value: imp.module
1140
+ });
1141
+ break;
1142
+ }
1143
+ }
1144
+ }
1145
+ if (policy.allowedImports && policy.allowedImports.length > 0) {
1146
+ const isAllowed = policy.allowedImports.some((pattern) => pattern.test(imp.module));
1147
+ if (!isAllowed) {
1148
+ const alreadyBlocked = violations.some((v) => v.type === "blocked-import" && v.value === imp.module);
1149
+ if (!alreadyBlocked) {
1150
+ violations.push({
1151
+ type: "disallowed-import",
1152
+ message: `Import '${imp.module}' is not in the allowed imports list`,
1153
+ location: getLocation(source, imp.index),
1154
+ value: imp.module
1155
+ });
1156
+ }
1157
+ }
1158
+ }
1159
+ }
1160
+ return violations;
1161
+ }
1162
+ function validateSize(size, policy = DEFAULT_SECURITY_POLICY) {
1163
+ const maxSize = policy.maxBundleSize ?? DEFAULT_SECURITY_POLICY.maxBundleSize ?? 512e3;
1164
+ if (size > maxSize) {
1165
+ return {
1166
+ type: "size-exceeded",
1167
+ message: `Bundle size (${formatBytes(size)}) exceeds maximum allowed (${formatBytes(maxSize)})`,
1168
+ value: String(size)
1169
+ };
1170
+ }
1171
+ return void 0;
1172
+ }
1173
+ function mergePolicy(userPolicy) {
1174
+ if (!userPolicy) {
1175
+ return { ...DEFAULT_SECURITY_POLICY };
1176
+ }
1177
+ return {
1178
+ allowedImports: userPolicy.allowedImports ?? DEFAULT_SECURITY_POLICY.allowedImports,
1179
+ blockedImports: userPolicy.blockedImports ?? DEFAULT_SECURITY_POLICY.blockedImports,
1180
+ maxBundleSize: userPolicy.maxBundleSize ?? DEFAULT_SECURITY_POLICY.maxBundleSize,
1181
+ maxTransformTime: userPolicy.maxTransformTime ?? DEFAULT_SECURITY_POLICY.maxTransformTime,
1182
+ noEval: userPolicy.noEval ?? DEFAULT_SECURITY_POLICY.noEval,
1183
+ noDynamicImports: userPolicy.noDynamicImports ?? DEFAULT_SECURITY_POLICY.noDynamicImports,
1184
+ noRequire: userPolicy.noRequire ?? DEFAULT_SECURITY_POLICY.noRequire,
1185
+ allowedGlobals: userPolicy.allowedGlobals ?? DEFAULT_SECURITY_POLICY.allowedGlobals
1186
+ };
1187
+ }
1188
+ function getLocation(source, index) {
1189
+ const lines = source.slice(0, index).split("\n");
1190
+ return {
1191
+ line: lines.length,
1192
+ column: lines[lines.length - 1].length + 1
1193
+ };
1194
+ }
1195
+ function formatBytes(bytes) {
1196
+ if (bytes < 1024) return `${bytes} B`;
1197
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
1198
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1199
+ }
1200
+ var SecurityError = class extends Error {
1201
+ violations;
1202
+ constructor(message, violations) {
1203
+ super(message);
1204
+ this.name = "SecurityError";
1205
+ this.violations = violations;
1206
+ }
1207
+ };
1208
+ function throwOnViolations(violations) {
1209
+ if (violations.length > 0) {
1210
+ const message = violations.map((v) => v.message).join("; ");
1211
+ throw new SecurityError(`Security policy violation: ${message}`, violations);
1212
+ }
1213
+ }
1214
+
1215
+ // libs/ui/src/bundler/sandbox/enclave-adapter.ts
1216
+ var import_enclave_vm = require("enclave-vm");
1217
+ var DEFAULT_ENCLAVE_OPTIONS = {
1218
+ securityLevel: "SECURE",
1219
+ timeout: 5e3,
1220
+ maxIterations: 1e4,
1221
+ validate: true,
1222
+ transform: true
1223
+ };
1224
+ var STRICT_SECURITY_BLOCKED_IMPORTS_THRESHOLD = 10;
1225
+ function mapSecurityLevel(policy) {
1226
+ if (policy?.blockedImports && policy.blockedImports.length > STRICT_SECURITY_BLOCKED_IMPORTS_THRESHOLD) {
1227
+ return "STRICT";
1228
+ }
1229
+ return "SECURE";
1230
+ }
1231
+ function createJSXRuntime(React) {
1232
+ const R = React;
1233
+ return {
1234
+ jsx: (type, props, key) => {
1235
+ const { children, ...rest } = props;
1236
+ return R.createElement(type, key ? { ...rest, key } : rest, children);
1237
+ },
1238
+ jsxs: (type, props, key) => {
1239
+ const { children, ...rest } = props;
1240
+ return R.createElement(type, key ? { ...rest, key } : rest, children);
1241
+ },
1242
+ jsxDEV: (type, props, key, _isStaticChildren, _source, _self) => {
1243
+ const { children, ...rest } = props;
1244
+ return R.createElement(type, key ? { ...rest, key } : rest, children);
1245
+ },
1246
+ Fragment: R.Fragment
1247
+ };
1248
+ }
1249
+ var DANGEROUS_GLOBAL_KEYS = /* @__PURE__ */ new Set([
1250
+ "process",
1251
+ "require",
1252
+ "__dirname",
1253
+ "__filename",
1254
+ "Buffer",
1255
+ "eval",
1256
+ "Function",
1257
+ "constructor",
1258
+ "global",
1259
+ "globalThis",
1260
+ "module",
1261
+ "exports",
1262
+ "__proto__"
1263
+ ]);
1264
+ function sanitizeGlobalKey(key) {
1265
+ return key.replace(/[^a-zA-Z0-9_$]/g, "_");
1266
+ }
1267
+ function buildGlobals(context) {
1268
+ const globals = {};
1269
+ if (context.React) {
1270
+ globals["React"] = context.React;
1271
+ }
1272
+ if (context.ReactDOM) {
1273
+ globals["ReactDOM"] = context.ReactDOM;
1274
+ }
1275
+ if (context.React) {
1276
+ const jsxRuntime = createJSXRuntime(context.React);
1277
+ globals["__jsx"] = jsxRuntime["jsx"];
1278
+ globals["__jsxs"] = jsxRuntime["jsxs"];
1279
+ globals["__jsxDEV"] = jsxRuntime["jsxDEV"];
1280
+ globals["Fragment"] = jsxRuntime["Fragment"];
1281
+ }
1282
+ if (context.modules) {
1283
+ for (const [key, value] of Object.entries(context.modules)) {
1284
+ const sanitizedKey = sanitizeGlobalKey(key);
1285
+ if (DANGEROUS_GLOBAL_KEYS.has(sanitizedKey)) {
1286
+ throw new ExecutionError(
1287
+ `Dangerous module key '${key}' (sanitized: '${sanitizedKey}') is not allowed in execution context`,
1288
+ { code: "SECURITY_VIOLATION" }
1289
+ );
1290
+ }
1291
+ globals[sanitizedKey] = value;
1292
+ }
1293
+ }
1294
+ if (context.globals) {
1295
+ for (const [key, value] of Object.entries(context.globals)) {
1296
+ if (DANGEROUS_GLOBAL_KEYS.has(key)) {
1297
+ throw new ExecutionError(`Dangerous global key '${key}' is not allowed in execution context`, {
1298
+ code: "SECURITY_VIOLATION"
1299
+ });
1300
+ }
1301
+ const sanitizedKey = sanitizeGlobalKey(key);
1302
+ if (DANGEROUS_GLOBAL_KEYS.has(sanitizedKey)) {
1303
+ throw new ExecutionError(
1304
+ `Dangerous global key '${key}' (sanitized: '${sanitizedKey}') is not allowed in execution context`,
1305
+ { code: "SECURITY_VIOLATION" }
1306
+ );
1307
+ }
1308
+ globals[sanitizedKey] = value;
1309
+ }
1310
+ }
1311
+ return globals;
1312
+ }
1313
+ function buildRequireFunction(context) {
1314
+ const normalizedContextModules = {};
1315
+ if (context.modules) {
1316
+ for (const [key, value] of Object.entries(context.modules)) {
1317
+ normalizedContextModules[key.toLowerCase()] = value;
1318
+ }
1319
+ }
1320
+ const modules = {
1321
+ react: context.React,
1322
+ "react-dom": context.ReactDOM,
1323
+ "react/jsx-runtime": context.React ? createJSXRuntime(context.React) : void 0,
1324
+ "react/jsx-dev-runtime": context.React ? createJSXRuntime(context.React) : void 0,
1325
+ ...normalizedContextModules
1326
+ };
1327
+ return (id) => {
1328
+ const normalizedId = id.toLowerCase();
1329
+ if (normalizedId in modules) {
1330
+ const mod = modules[normalizedId];
1331
+ if (mod === void 0) {
1332
+ throw new Error(`Module '${id}' is not available. Did you forget to provide it in the context?`);
1333
+ }
1334
+ return mod;
1335
+ }
1336
+ throw new Error(`Module '${id}' is not available in the sandbox environment`);
1337
+ };
1338
+ }
1339
+ async function executeCode(code, context = {}) {
1340
+ const consoleOutput = [];
1341
+ const globals = buildGlobals(context);
1342
+ globals["console"] = {
1343
+ log: (...args) => {
1344
+ consoleOutput.push(args.map(String).join(" "));
1345
+ },
1346
+ info: (...args) => {
1347
+ consoleOutput.push(`[INFO] ${args.map(String).join(" ")}`);
1348
+ },
1349
+ warn: (...args) => {
1350
+ consoleOutput.push(`[WARN] ${args.map(String).join(" ")}`);
1351
+ },
1352
+ error: (...args) => {
1353
+ consoleOutput.push(`[ERROR] ${args.map(String).join(" ")}`);
1354
+ },
1355
+ debug: (...args) => {
1356
+ consoleOutput.push(`[DEBUG] ${args.map(String).join(" ")}`);
1357
+ },
1358
+ trace: () => {
1359
+ },
1360
+ dir: () => {
1361
+ },
1362
+ table: () => {
1363
+ },
1364
+ group: () => {
1365
+ },
1366
+ groupEnd: () => {
1367
+ },
1368
+ time: () => {
1369
+ },
1370
+ timeEnd: () => {
1371
+ },
1372
+ assert: () => {
1373
+ },
1374
+ clear: () => {
1375
+ },
1376
+ count: () => {
1377
+ },
1378
+ countReset: () => {
1379
+ }
1380
+ };
1381
+ globals["require"] = buildRequireFunction(context);
1382
+ const enclave = new import_enclave_vm.Enclave({
1383
+ ...DEFAULT_ENCLAVE_OPTIONS,
1384
+ timeout: context.timeout ?? DEFAULT_ENCLAVE_OPTIONS.timeout,
1385
+ maxIterations: context.maxIterations ?? DEFAULT_ENCLAVE_OPTIONS.maxIterations,
1386
+ securityLevel: mapSecurityLevel(context.security),
1387
+ globals,
1388
+ allowFunctionsInGlobals: true
1389
+ // Required for React components
1390
+ });
1391
+ try {
1392
+ const wrappedCode = `
1393
+ const module = { exports: {} };
1394
+ const exports = module.exports;
1395
+ const __filename = 'widget.js';
1396
+ const __dirname = '/';
1397
+ ${code}
1398
+ return module.exports;
1399
+ `;
1400
+ const result = await enclave.run(wrappedCode);
1401
+ if (!result.success) {
1402
+ const errorMessage = result.error?.message ?? "Execution failed";
1403
+ const errorCode = result.error?.code;
1404
+ if (errorCode === "TIMEOUT") {
1405
+ throw new ExecutionError(`Execution timed out after ${context.timeout ?? DEFAULT_ENCLAVE_OPTIONS.timeout}ms`, {
1406
+ code: "TIMEOUT"
1407
+ });
1408
+ }
1409
+ if (errorCode === "MAX_ITERATIONS") {
1410
+ throw new ExecutionError(
1411
+ `Maximum iterations exceeded (${context.maxIterations ?? DEFAULT_ENCLAVE_OPTIONS.maxIterations})`,
1412
+ {
1413
+ code: "MAX_ITERATIONS"
1414
+ }
1415
+ );
1416
+ }
1417
+ if (errorCode === "VALIDATION_ERROR") {
1418
+ throw new ExecutionError(`Security validation failed: ${errorMessage}`, { code: "SECURITY_VIOLATION" });
1419
+ }
1420
+ throw new ExecutionError(errorMessage, result.error);
1421
+ }
1422
+ return {
1423
+ exports: result.value,
1424
+ executionTime: result.stats.duration,
1425
+ consoleOutput: consoleOutput.length > 0 ? consoleOutput : void 0
1426
+ };
1427
+ } finally {
1428
+ enclave.dispose();
1429
+ }
1430
+ }
1431
+ async function executeDefault(code, context = {}) {
1432
+ const result = await executeCode(code, context);
1433
+ if ("default" in result.exports) {
1434
+ return result.exports.default;
1435
+ }
1436
+ const exportKeys = Object.keys(result.exports);
1437
+ if (exportKeys.length === 0) {
1438
+ throw new ExecutionError("Code did not export any values");
1439
+ }
1440
+ if (exportKeys.length === 1) {
1441
+ return result.exports[exportKeys[0]];
1442
+ }
1443
+ return result.exports;
1444
+ }
1445
+ var ExecutionError = class extends Error {
1446
+ /** Error code for categorization */
1447
+ code;
1448
+ constructor(message, cause) {
1449
+ super(message, { cause });
1450
+ this.name = "ExecutionError";
1451
+ if (cause && typeof cause === "object" && "code" in cause) {
1452
+ this.code = cause.code;
1453
+ }
1454
+ }
1455
+ };
1456
+ function isExecutionError(error) {
1457
+ return error instanceof ExecutionError;
1458
+ }
1459
+
1460
+ // libs/ui/src/utils/escape-html.ts
1461
+ function escapeHtml(str) {
1462
+ if (str === null || str === void 0) {
1463
+ return "";
1464
+ }
1465
+ const s = String(str);
1466
+ 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");
1467
+ }
1468
+ function escapeHtmlAttr(str) {
1469
+ return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
1470
+ }
1471
+
1472
+ // libs/ui/src/universal/types.ts
1473
+ var UNIVERSAL_CDN = {
1474
+ esm: {
1475
+ reactMarkdown: "https://esm.sh/react-markdown@9",
1476
+ mdxReact: "https://esm.sh/@mdx-js/react@3",
1477
+ remarkGfm: "https://esm.sh/remark-gfm@4"
1478
+ }
1479
+ // Note: These libraries are not available on cdnjs
1480
+ // For Claude, we use inline implementations
1481
+ };
1482
+ function detectContentType(source) {
1483
+ if (typeof source === "function") {
1484
+ return "react";
1485
+ }
1486
+ if (typeof source !== "string") {
1487
+ return "html";
1488
+ }
1489
+ const hasModuleSyntax = /^import\s+/m.test(source) || /^export\s+(default\s+)?/m.test(source) || /^const\s+\w+\s*=\s*\([^)]*\)\s*=>/m.test(source) || // Arrow function components
1490
+ /^function\s+\w+\s*\(/m.test(source);
1491
+ const hasJsxTags = /<[A-Z][a-zA-Z]*/.test(source);
1492
+ const hasMarkdown = /^#{1,6}\s/m.test(source) || /^\*\s/m.test(source) || /^-\s/m.test(source) || /^\d+\.\s/m.test(source);
1493
+ if (hasModuleSyntax && hasJsxTags) {
1494
+ return "react";
1495
+ }
1496
+ if (hasJsxTags && hasMarkdown && !hasModuleSyntax) {
1497
+ return "mdx";
1498
+ }
1499
+ if (hasMarkdown || /\*\*[^*]+\*\*/.test(source) || /\[[^\]]+\]\([^)]+\)/.test(source)) {
1500
+ return "markdown";
1501
+ }
1502
+ if (hasJsxTags && !hasModuleSyntax) {
1503
+ return "mdx";
1504
+ }
1505
+ return "html";
1506
+ }
1507
+
1508
+ // libs/ui/src/universal/cached-runtime.ts
1509
+ var RUNTIME_PLACEHOLDERS = {
1510
+ /** Placeholder for transpiled component code */
1511
+ COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/",
1512
+ /** Placeholder for data injection */
1513
+ DATA_INJECTION: "/*__FRONTMCP_DATA_INJECTION__*/",
1514
+ /** Placeholder for custom components */
1515
+ CUSTOM_COMPONENTS: "/*__FRONTMCP_CUSTOM_COMPONENTS__*/"
1516
+ };
1517
+ var runtimeCache = /* @__PURE__ */ new Map();
1518
+ var DEFAULT_CACHE_CONFIG = {
1519
+ maxEntries: 10,
1520
+ ttl: 0
1521
+ // Forever by default
1522
+ };
1523
+ function generateCacheKey(options) {
1524
+ const securityKey = options.contentSecurity ? [
1525
+ options.contentSecurity.allowUnsafeLinks ? "unsafeLinks" : "",
1526
+ options.contentSecurity.allowInlineScripts ? "unsafeScripts" : "",
1527
+ options.contentSecurity.bypassSanitization ? "bypass" : ""
1528
+ ].filter(Boolean).join("+") || "secure" : "secure";
1529
+ return [
1530
+ options.cdnType,
1531
+ options.includeMarkdown ? "md" : "",
1532
+ options.includeMdx ? "mdx" : "",
1533
+ options.minify ? "min" : "",
1534
+ securityKey
1535
+ ].filter(Boolean).join(":");
1536
+ }
1537
+ function buildStoreRuntime() {
1538
+ return `
1539
+ // FrontMCP Store (Vendor)
1540
+ (function() {
1541
+ var state = {
1542
+ toolName: null,
1543
+ input: null,
1544
+ output: null,
1545
+ content: null,
1546
+ structuredContent: null,
1547
+ loading: false,
1548
+ error: null
1549
+ };
1550
+
1551
+ var listeners = new Set();
1552
+
1553
+ window.__frontmcp = {
1554
+ getState: function() { return state; },
1555
+ setState: function(partial) {
1556
+ state = Object.assign({}, state, partial);
1557
+ listeners.forEach(function(fn) { fn(); });
1558
+ },
1559
+ subscribe: function(fn) {
1560
+ listeners.add(fn);
1561
+ return function() { listeners.delete(fn); };
1562
+ },
1563
+ reset: function() {
1564
+ state = {
1565
+ toolName: null,
1566
+ input: null,
1567
+ output: null,
1568
+ content: null,
1569
+ structuredContent: null,
1570
+ loading: false,
1571
+ error: null
1572
+ };
1573
+ },
1574
+ context: state,
1575
+ setContext: function(ctx) {
1576
+ this.setState(ctx);
1577
+ }
1578
+ };
1579
+
1580
+ // React hooks
1581
+ window.useFrontMCPStore = function() {
1582
+ var store = window.__frontmcp;
1583
+ return React.useSyncExternalStore(
1584
+ store.subscribe,
1585
+ store.getState,
1586
+ store.getState
1587
+ );
1588
+ };
1589
+
1590
+ window.useToolOutput = function() {
1591
+ return window.useFrontMCPStore().output;
1592
+ };
1593
+
1594
+ window.useToolInput = function() {
1595
+ return window.useFrontMCPStore().input;
1596
+ };
1597
+
1598
+ window.useContent = function() {
1599
+ return window.useFrontMCPStore().content;
1600
+ };
1601
+ })();
1602
+ `;
1603
+ }
1604
+ function buildRequireShim() {
1605
+ return `
1606
+ // Module Require Shim (Vendor)
1607
+ (function() {
1608
+ window.__moduleCache = {};
1609
+ window.require = function(moduleName) {
1610
+ if (window.__moduleCache[moduleName]) {
1611
+ return window.__moduleCache[moduleName];
1612
+ }
1613
+
1614
+ var moduleMap = {
1615
+ 'react': function() { return window.React; },
1616
+ 'react-dom': function() { return window.ReactDOM; },
1617
+ 'react-dom/client': function() { return window.ReactDOM; },
1618
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
1619
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
1620
+ '@frontmcp/ui': function() { return window.frontmcp_ui_namespaceObject; },
1621
+ '@frontmcp/ui/react': function() { return window.frontmcp_ui_namespaceObject; }
1622
+ };
1623
+
1624
+ var resolver = moduleMap[moduleName];
1625
+ if (resolver) {
1626
+ var mod = resolver();
1627
+ window.__moduleCache[moduleName] = mod;
1628
+ return mod;
1629
+ }
1630
+
1631
+ console.warn('[FrontMCP] Unknown module:', moduleName);
1632
+ return {};
1633
+ };
1634
+ })();
1635
+ `;
1636
+ }
1637
+ function buildInlineMarkdownParser(options) {
1638
+ const allowUnsafeLinks = options?.contentSecurity?.bypassSanitization || options?.contentSecurity?.allowUnsafeLinks;
1639
+ return `
1640
+ // Inline Markdown Parser (Vendor)
1641
+ (function() {
1642
+ // XSS protection settings (configured at build time)
1643
+ // Set to true if contentSecurity.allowUnsafeLinks or bypassSanitization is enabled
1644
+ var __allowUnsafeLinks = ${allowUnsafeLinks ? "true" : "false"};
1645
+
1646
+ // URL scheme validation to prevent XSS via javascript: URLs
1647
+ function isSafeUrl(url) {
1648
+ // If unsafe links are explicitly allowed, skip validation
1649
+ if (__allowUnsafeLinks) return true;
1650
+ if (!url) return false;
1651
+ var lower = url.toLowerCase().trim();
1652
+ return lower.startsWith('http://') ||
1653
+ lower.startsWith('https://') ||
1654
+ lower.startsWith('/') ||
1655
+ lower.startsWith('#') ||
1656
+ lower.startsWith('mailto:');
1657
+ }
1658
+
1659
+ function parseMarkdown(md) {
1660
+ var html = md;
1661
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1662
+ html = html.replace(/^######\\s+(.*)$/gm, '<h6>$1</h6>');
1663
+ html = html.replace(/^#####\\s+(.*)$/gm, '<h5>$1</h5>');
1664
+ html = html.replace(/^####\\s+(.*)$/gm, '<h4>$1</h4>');
1665
+ html = html.replace(/^###\\s+(.*)$/gm, '<h3>$1</h3>');
1666
+ html = html.replace(/^##\\s+(.*)$/gm, '<h2>$1</h2>');
1667
+ html = html.replace(/^#\\s+(.*)$/gm, '<h1>$1</h1>');
1668
+ html = html.replace(/\\*\\*\\*(.+?)\\*\\*\\*/g, '<strong><em>$1</em></strong>');
1669
+ html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');
1670
+ html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');
1671
+ html = html.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
1672
+ // Links - validate URL scheme to prevent XSS (unless bypassed)
1673
+ html = html.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, function(match, text, url) {
1674
+ return isSafeUrl(url) ? '<a href="' + url + '">' + text + '</a>' : text;
1675
+ });
1676
+ html = html.replace(/^[-*]\\s+(.*)$/gm, '<li>$1</li>');
1677
+ html = html.replace(/\\n\\n+/g, '</p><p>');
1678
+ html = '<p>' + html + '</p>';
1679
+ return html;
1680
+ }
1681
+
1682
+ window.__frontmcp.parseMarkdown = parseMarkdown;
1683
+
1684
+ window.ReactMarkdown = function(props) {
1685
+ var html = parseMarkdown(props.children || '');
1686
+ return React.createElement('div', {
1687
+ className: 'frontmcp-markdown prose',
1688
+ dangerouslySetInnerHTML: { __html: html }
1689
+ });
1690
+ };
1691
+ })();
1692
+ `;
1693
+ }
1694
+ function buildRenderersRuntime(options) {
1695
+ const bypassSanitization = options?.contentSecurity?.bypassSanitization;
1696
+ const allowInlineScripts = bypassSanitization || options?.contentSecurity?.allowInlineScripts;
1697
+ return `
1698
+ // Universal Renderers (Vendor)
1699
+ (function() {
1700
+ var renderers = {};
1701
+
1702
+ // XSS protection settings (configured at build time)
1703
+ // Set to true if contentSecurity.allowInlineScripts or bypassSanitization is enabled
1704
+ var __allowInlineScripts = ${allowInlineScripts ? "true" : "false"};
1705
+
1706
+ renderers.html = {
1707
+ type: 'html',
1708
+ priority: 0,
1709
+ canHandle: function(c) { return c.type === 'html'; },
1710
+ render: function(c, ctx) {
1711
+ var html = c.source;
1712
+ // Apply XSS protection unless bypassed
1713
+ if (!__allowInlineScripts) {
1714
+ // Remove script tags and event handlers to prevent XSS
1715
+ html = html.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');
1716
+ html = html.replace(/\\s+on\\w+\\s*=/gi, ' data-removed-handler=');
1717
+ }
1718
+ return React.createElement('div', {
1719
+ className: 'frontmcp-html-content',
1720
+ dangerouslySetInnerHTML: { __html: html }
1721
+ });
1722
+ }
1723
+ };
1724
+
1725
+ renderers.markdown = {
1726
+ type: 'markdown',
1727
+ priority: 10,
1728
+ canHandle: function(c) {
1729
+ if (c.type === 'markdown') return true;
1730
+ if (typeof c.source !== 'string') return false;
1731
+ var s = c.source;
1732
+ return /^#{1,6}\\s/m.test(s) || /^[-*]\\s/m.test(s) || /\\*\\*[^*]+\\*\\*/.test(s);
1733
+ },
1734
+ render: function(c, ctx) {
1735
+ if (window.ReactMarkdown) {
1736
+ return React.createElement(window.ReactMarkdown, {
1737
+ children: c.source,
1738
+ components: Object.assign({}, ctx.components, c.components)
1739
+ });
1740
+ }
1741
+ var html = window.__frontmcp.parseMarkdown ? window.__frontmcp.parseMarkdown(c.source) : c.source;
1742
+ return React.createElement('div', {
1743
+ className: 'frontmcp-markdown prose',
1744
+ dangerouslySetInnerHTML: { __html: html }
1745
+ });
1746
+ }
1747
+ };
1748
+
1749
+ renderers.react = {
1750
+ type: 'react',
1751
+ priority: 30,
1752
+ canHandle: function(c) { return c.type === 'react' || typeof c.source === 'function'; },
1753
+ render: function(c, ctx) {
1754
+ var Component = c.source;
1755
+ var props = Object.assign({
1756
+ output: ctx.output,
1757
+ input: ctx.input,
1758
+ state: ctx.state,
1759
+ data: ctx.output // Alias for convenience
1760
+ }, c.props);
1761
+ return React.createElement(Component, props);
1762
+ }
1763
+ };
1764
+
1765
+ renderers.mdx = {
1766
+ type: 'mdx',
1767
+ priority: 20,
1768
+ canHandle: function(c) {
1769
+ if (c.type === 'mdx') return true;
1770
+ if (typeof c.source !== 'string') return false;
1771
+ var s = c.source;
1772
+ return /<[A-Z][a-zA-Z]*/.test(s) && /^#{1,6}\\s/m.test(s);
1773
+ },
1774
+ render: function(c, ctx) {
1775
+ if (typeof c.compiledContent === 'function') {
1776
+ var MDXContent = c.compiledContent;
1777
+ return React.createElement(MDXContent, {
1778
+ output: ctx.output,
1779
+ input: ctx.input,
1780
+ components: Object.assign({}, ctx.components, c.components)
1781
+ });
1782
+ }
1783
+ return React.createElement('div', { className: 'frontmcp-mdx-fallback' }, [
1784
+ React.createElement('div', {
1785
+ key: 'warn',
1786
+ className: 'bg-yellow-50 border border-yellow-200 rounded p-2 mb-2 text-sm text-yellow-800'
1787
+ }, 'MDX requires pre-compilation. Showing raw content.'),
1788
+ React.createElement('pre', {
1789
+ key: 'pre',
1790
+ className: 'bg-gray-100 p-4 rounded text-sm overflow-auto'
1791
+ }, c.source)
1792
+ ]);
1793
+ }
1794
+ };
1795
+
1796
+ var sortedRenderers = [renderers.react, renderers.mdx, renderers.markdown, renderers.html];
1797
+
1798
+ window.__frontmcp.detectRenderer = function(content) {
1799
+ if (content.type && renderers[content.type]) {
1800
+ return renderers[content.type];
1801
+ }
1802
+ for (var i = 0; i < sortedRenderers.length; i++) {
1803
+ if (sortedRenderers[i].canHandle(content)) {
1804
+ return sortedRenderers[i];
1805
+ }
1806
+ }
1807
+ return renderers.html;
1808
+ };
1809
+
1810
+ window.__frontmcp.renderContent = function(content, context) {
1811
+ var renderer = window.__frontmcp.detectRenderer(content);
1812
+ return renderer.render(content, context);
1813
+ };
1814
+
1815
+ window.__frontmcp.renderers = renderers;
1816
+ })();
1817
+ `;
1818
+ }
1819
+ function buildUIComponentsRuntime() {
1820
+ return `
1821
+ // UI Components (Vendor)
1822
+ (function() {
1823
+ window.Card = function(props) {
1824
+ var children = props.children;
1825
+ var title = props.title;
1826
+ var className = props.className || '';
1827
+ return React.createElement('div', {
1828
+ className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
1829
+ }, [
1830
+ title && React.createElement('div', {
1831
+ key: 'header',
1832
+ className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
1833
+ }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
1834
+ React.createElement('div', { key: 'body', className: 'p-4' }, children)
1835
+ ]);
1836
+ };
1837
+
1838
+ window.Badge = function(props) {
1839
+ var children = props.children;
1840
+ var variant = props.variant || 'default';
1841
+ var variantClasses = {
1842
+ default: 'bg-gray-100 text-gray-800',
1843
+ success: 'bg-green-100 text-green-800',
1844
+ warning: 'bg-yellow-100 text-yellow-800',
1845
+ error: 'bg-red-100 text-red-800',
1846
+ info: 'bg-blue-100 text-blue-800'
1847
+ };
1848
+ return React.createElement('span', {
1849
+ className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
1850
+ }, children);
1851
+ };
1852
+
1853
+ window.Button = function(props) {
1854
+ var children = props.children;
1855
+ var variant = props.variant || 'primary';
1856
+ var onClick = props.onClick;
1857
+ var disabled = props.disabled;
1858
+ var variantClasses = {
1859
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
1860
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
1861
+ outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
1862
+ danger: 'bg-red-600 text-white hover:bg-red-700'
1863
+ };
1864
+ return React.createElement('button', {
1865
+ className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
1866
+ (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
1867
+ (variantClasses[variant] || variantClasses.primary),
1868
+ onClick: onClick,
1869
+ disabled: disabled
1870
+ }, children);
1871
+ };
1872
+
1873
+ // Export to namespace
1874
+ window.frontmcp_ui_namespaceObject = Object.assign({}, window.React || {}, {
1875
+ useToolOutput: window.useToolOutput,
1876
+ useToolInput: window.useToolInput,
1877
+ useMcpBridgeContext: function() { return window.__frontmcp.context; },
1878
+ useCallTool: function() { return function() { return Promise.resolve(null); }; },
1879
+ Card: window.Card,
1880
+ Badge: window.Badge,
1881
+ Button: window.Button
1882
+ });
1883
+ })();
1884
+ `;
1885
+ }
1886
+ function buildUniversalAppRuntime() {
1887
+ return `
1888
+ // Universal App (Vendor)
1889
+ (function() {
1890
+ var LoadingSpinner = function() {
1891
+ return React.createElement('div', {
1892
+ className: 'frontmcp-loading flex items-center justify-center min-h-[200px]'
1893
+ }, React.createElement('div', {
1894
+ className: 'frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin'
1895
+ }));
1896
+ };
1897
+
1898
+ var ErrorDisplay = function(props) {
1899
+ return React.createElement('div', {
1900
+ className: 'frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800'
1901
+ }, [
1902
+ React.createElement('div', { key: 'title', className: 'font-medium' }, 'Error'),
1903
+ React.createElement('div', { key: 'msg', className: 'text-sm mt-1' }, props.error)
1904
+ ]);
1905
+ };
1906
+
1907
+ var EmptyState = function() {
1908
+ return React.createElement('div', {
1909
+ className: 'frontmcp-empty text-gray-500 text-center py-8'
1910
+ }, 'No content to display');
1911
+ };
1912
+
1913
+ window.__frontmcp.UniversalApp = function(props) {
1914
+ var state = window.useFrontMCPStore();
1915
+
1916
+ if (state.loading) {
1917
+ return props.fallback || React.createElement(LoadingSpinner);
1918
+ }
1919
+
1920
+ if (state.error) {
1921
+ var ErrorComp = props.errorFallback || ErrorDisplay;
1922
+ return React.createElement(ErrorComp, { error: state.error });
1923
+ }
1924
+
1925
+ var content = props.content || state.content;
1926
+
1927
+ if (!content) {
1928
+ return React.createElement(EmptyState);
1929
+ }
1930
+
1931
+ var context = {
1932
+ output: state.output,
1933
+ input: state.input,
1934
+ state: state,
1935
+ components: props.components || {}
1936
+ };
1937
+
1938
+ var rendered = window.__frontmcp.renderContent(content, context);
1939
+ return React.createElement('div', { className: 'frontmcp-content' }, rendered);
1940
+ };
1941
+
1942
+ window.__frontmcp.LoadingSpinner = LoadingSpinner;
1943
+ window.__frontmcp.ErrorDisplay = ErrorDisplay;
1944
+ window.__frontmcp.EmptyState = EmptyState;
1945
+ })();
1946
+ `;
1947
+ }
1948
+ function buildComponentWrapper() {
1949
+ return `
1950
+ // Component Execution (App Chunk)
1951
+ (function() {
1952
+ ${RUNTIME_PLACEHOLDERS.COMPONENT_CODE}
1953
+ })();
1954
+ `;
1955
+ }
1956
+ function buildDataInjectionWrapper() {
1957
+ return `
1958
+ // Data Injection (App Chunk)
1959
+ (function() {
1960
+ ${RUNTIME_PLACEHOLDERS.DATA_INJECTION}
1961
+ })();
1962
+ `;
1963
+ }
1964
+ function buildCustomComponentsWrapper() {
1965
+ return `
1966
+ // Custom Components (App Chunk)
1967
+ (function() {
1968
+ ${RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS}
1969
+ })();
1970
+ `;
1971
+ }
1972
+ function buildCdnImports(options) {
1973
+ const parts = [];
1974
+ if (options.cdnType === "esm") {
1975
+ if (options.includeMarkdown) {
1976
+ parts.push(`
1977
+ <script type="module">
1978
+ import ReactMarkdown from '${UNIVERSAL_CDN.esm.reactMarkdown}';
1979
+ window.ReactMarkdown = ReactMarkdown;
1980
+ </script>`);
1981
+ }
1982
+ if (options.includeMdx) {
1983
+ parts.push(`
1984
+ <script type="module">
1985
+ import { MDXProvider } from '${UNIVERSAL_CDN.esm.mdxReact}';
1986
+ window.MDXProvider = MDXProvider;
1987
+ </script>`);
1988
+ }
1989
+ }
1990
+ return parts.join("\n");
1991
+ }
1992
+ function getCachedRuntime(options, config = {}) {
1993
+ const cacheKey = generateCacheKey(options);
1994
+ const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...config };
1995
+ const cached = runtimeCache.get(cacheKey);
1996
+ if (cached) {
1997
+ if (cacheConfig.ttl === 0 || Date.now() - cached.cachedAt < cacheConfig.ttl) {
1998
+ return {
1999
+ vendorScript: cached.script,
2000
+ appTemplate: buildAppTemplate(),
2001
+ cdnImports: cached.cdnImports,
2002
+ vendorSize: cached.size,
2003
+ cached: true,
2004
+ cacheKey
2005
+ };
2006
+ }
2007
+ runtimeCache.delete(cacheKey);
2008
+ }
2009
+ const vendorParts = [buildStoreRuntime(), buildRequireShim()];
2010
+ if (options.cdnType === "umd" || options.includeMarkdown) {
2011
+ vendorParts.push(buildInlineMarkdownParser(options));
2012
+ }
2013
+ vendorParts.push(buildRenderersRuntime(options));
2014
+ vendorParts.push(buildUIComponentsRuntime());
2015
+ vendorParts.push(buildUniversalAppRuntime());
2016
+ let vendorScript = vendorParts.join("\n");
2017
+ if (options.minify) {
2018
+ vendorScript = minifyScript(vendorScript);
2019
+ }
2020
+ const cdnImports = buildCdnImports(options);
2021
+ const entry = {
2022
+ script: vendorScript,
2023
+ cdnImports,
2024
+ size: vendorScript.length,
2025
+ cacheKey,
2026
+ cachedAt: Date.now()
2027
+ };
2028
+ if (runtimeCache.size >= cacheConfig.maxEntries) {
2029
+ const oldestKey = runtimeCache.keys().next().value;
2030
+ if (oldestKey) {
2031
+ runtimeCache.delete(oldestKey);
2032
+ }
2033
+ }
2034
+ runtimeCache.set(cacheKey, entry);
2035
+ return {
2036
+ vendorScript,
2037
+ appTemplate: buildAppTemplate(),
2038
+ cdnImports,
2039
+ vendorSize: vendorScript.length,
2040
+ cached: false,
2041
+ cacheKey
2042
+ };
2043
+ }
2044
+ function buildAppTemplate() {
2045
+ return [buildCustomComponentsWrapper(), buildComponentWrapper(), buildDataInjectionWrapper()].join("\n");
2046
+ }
2047
+ function minifyScript(script) {
2048
+ return script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
2049
+ }
2050
+ function buildAppScript(appTemplate, componentCode, dataInjection, customComponents = "") {
2051
+ return appTemplate.replace(RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS, customComponents || "// No custom components").replace(RUNTIME_PLACEHOLDERS.COMPONENT_CODE, componentCode || "// No component code").replace(RUNTIME_PLACEHOLDERS.DATA_INJECTION, dataInjection);
2052
+ }
2053
+ function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
2054
+ const safeJson = (value) => {
2055
+ try {
2056
+ return JSON.stringify(value);
2057
+ } catch {
2058
+ return "null";
2059
+ }
2060
+ };
2061
+ if (hasComponent) {
2062
+ return `
2063
+ window.__frontmcp.setState({
2064
+ toolName: ${safeJson(toolName)},
2065
+ input: ${safeJson(input ?? null)},
2066
+ output: ${safeJson(output ?? null)},
2067
+ structuredContent: ${safeJson(structuredContent ?? null)},
2068
+ content: {
2069
+ type: 'react',
2070
+ source: window.__frontmcp_component
2071
+ },
2072
+ loading: false,
2073
+ error: null
2074
+ });`;
2075
+ }
2076
+ return `
2077
+ window.__frontmcp.setState({
2078
+ toolName: ${safeJson(toolName)},
2079
+ input: ${safeJson(input ?? null)},
2080
+ output: ${safeJson(output ?? null)},
2081
+ structuredContent: ${safeJson(structuredContent ?? null)},
2082
+ content: {
2083
+ type: ${safeJson(contentType)},
2084
+ source: ${safeJson(source)}
2085
+ },
2086
+ loading: false,
2087
+ error: null
2088
+ });`;
2089
+ }
2090
+ function buildComponentCode(transpiledCode) {
2091
+ return `
2092
+ // CommonJS module shim
2093
+ var module = { exports: {} };
2094
+ var exports = module.exports;
2095
+
2096
+ // Execute transpiled component
2097
+ ${transpiledCode}
2098
+
2099
+ // Capture component
2100
+ window.__frontmcp_component = module.exports.default || module.exports;`;
2101
+ }
2102
+
2103
+ // libs/ui/src/bundler/bundler.ts
2104
+ var esbuildTransform = null;
2105
+ async function loadEsbuild() {
2106
+ if (esbuildTransform !== null) {
2107
+ return esbuildTransform;
2108
+ }
2109
+ try {
2110
+ const esbuild = await import("esbuild");
2111
+ esbuildTransform = esbuild.transform;
2112
+ return esbuildTransform;
2113
+ } catch {
2114
+ try {
2115
+ const swc = await import("@swc/core");
2116
+ esbuildTransform = async (source, options) => {
2117
+ const opts = options;
2118
+ const result = await swc.transform(source, {
2119
+ jsc: {
2120
+ parser: {
2121
+ syntax: "typescript",
2122
+ tsx: opts.loader === "tsx" || opts.loader === "jsx"
2123
+ },
2124
+ transform: {
2125
+ react: {
2126
+ runtime: "automatic",
2127
+ development: false
2128
+ }
2129
+ },
2130
+ target: "es2020",
2131
+ minify: opts.minify ? { compress: true, mangle: true } : void 0
2132
+ },
2133
+ module: {
2134
+ type: "commonjs"
2135
+ },
2136
+ sourceMaps: opts.sourcemap ? true : false
2137
+ });
2138
+ return { code: result.code, map: result.map };
2139
+ };
2140
+ return esbuildTransform;
2141
+ } catch {
2142
+ console.warn(
2143
+ "[@frontmcp/ui/bundler] Neither esbuild nor @swc/core available. Install esbuild for best performance: npm install esbuild"
2144
+ );
2145
+ return null;
2146
+ }
2147
+ }
2148
+ }
2149
+ function sanitizeRootId(rootId) {
2150
+ const safeId = rootId.replace(/[^a-zA-Z0-9_-]/g, "");
2151
+ if (safeId !== rootId) {
2152
+ console.warn("[FrontMCP] rootId sanitized:", { original: rootId, sanitized: safeId });
2153
+ }
2154
+ return safeId || "frontmcp-root";
2155
+ }
2156
+ function sanitizeCss(css) {
2157
+ return css.replace(/<\/style>/gi, "\\3c/style\\3e");
2158
+ }
2159
+ var InMemoryBundler = class {
2160
+ cache;
2161
+ options;
2162
+ defaultSecurity;
2163
+ constructor(options = {}) {
2164
+ this.options = {
2165
+ ...DEFAULT_BUNDLER_OPTIONS,
2166
+ ...options,
2167
+ cache: {
2168
+ ...DEFAULT_BUNDLER_OPTIONS.cache,
2169
+ ...options.cache
2170
+ }
2171
+ };
2172
+ this.cache = new BundlerCache({
2173
+ maxSize: this.options.cache.maxSize,
2174
+ ttl: this.options.cache.ttl
2175
+ });
2176
+ this.defaultSecurity = mergePolicy(options.defaultSecurity);
2177
+ }
2178
+ /**
2179
+ * Bundle source code.
2180
+ *
2181
+ * @param options - Bundle options
2182
+ * @returns Bundle result
2183
+ */
2184
+ async bundle(options) {
2185
+ const startTime = performance.now();
2186
+ const opts = this.mergeOptions(options);
2187
+ if (!opts.skipCache && !this.options.cache.disabled) {
2188
+ const cacheKey = options.cacheKey ?? createCacheKey(options.source, opts);
2189
+ const cached = this.cache.get(cacheKey);
2190
+ if (cached) {
2191
+ return {
2192
+ ...cached,
2193
+ cached: true,
2194
+ metrics: {
2195
+ ...cached.metrics,
2196
+ cacheTime: performance.now() - startTime
2197
+ }
2198
+ };
2199
+ }
2200
+ }
2201
+ const security = mergePolicy(options.security ?? this.defaultSecurity);
2202
+ const violations = validateSource(options.source, security);
2203
+ throwOnViolations(violations);
2204
+ const sourceType = opts.sourceType === "auto" ? this.detectSourceType(options.source) : opts.sourceType;
2205
+ const transformStart = performance.now();
2206
+ const transformed = await this.transform(options.source, sourceType, opts);
2207
+ const transformTime = performance.now() - transformStart;
2208
+ const sizeViolation = validateSize(transformed.code.length, security);
2209
+ if (sizeViolation) {
2210
+ throwOnViolations([sizeViolation]);
2211
+ }
2212
+ const hash = hashContent(transformed.code);
2213
+ const result = {
2214
+ code: transformed.code,
2215
+ hash,
2216
+ cached: false,
2217
+ size: transformed.code.length,
2218
+ map: transformed.map,
2219
+ metrics: {
2220
+ transformTime,
2221
+ bundleTime: 0,
2222
+ // No separate bundle step for transform-only
2223
+ totalTime: performance.now() - startTime
2224
+ },
2225
+ sourceType,
2226
+ format: opts.format
2227
+ };
2228
+ if (!this.options.cache.disabled) {
2229
+ const cacheKey = options.cacheKey ?? createCacheKey(options.source, opts);
2230
+ this.cache.set(cacheKey, result);
2231
+ }
2232
+ return result;
2233
+ }
2234
+ /**
2235
+ * Bundle and execute for SSR.
2236
+ *
2237
+ * @param options - SSR bundle options
2238
+ * @returns SSR result with rendered HTML
2239
+ */
2240
+ async bundleSSR(options) {
2241
+ const startTime = performance.now();
2242
+ const bundleResult = await this.bundle({
2243
+ ...options,
2244
+ format: "cjs"
2245
+ // CommonJS for execution
2246
+ });
2247
+ let React;
2248
+ let ReactDOMServer;
2249
+ try {
2250
+ React = await import("react");
2251
+ ReactDOMServer = await import("react-dom/server");
2252
+ } catch {
2253
+ throw new Error("React and react-dom/server are required for SSR. Install them: npm install react react-dom");
2254
+ }
2255
+ const renderStart = performance.now();
2256
+ const Component = await executeDefault(bundleResult.code, {
2257
+ React,
2258
+ security: mergePolicy(options.security ?? this.defaultSecurity)
2259
+ });
2260
+ let html;
2261
+ try {
2262
+ const element = React.createElement(Component, options.context ?? {});
2263
+ html = ReactDOMServer.renderToString(element);
2264
+ } catch (error) {
2265
+ throw new ExecutionError(
2266
+ `SSR rendering failed: ${error instanceof Error ? error.message : String(error)}`,
2267
+ error
2268
+ );
2269
+ }
2270
+ const renderTime = performance.now() - renderStart;
2271
+ let hydrationScript;
2272
+ if (options.includeHydration) {
2273
+ hydrationScript = this.buildHydrationScript(bundleResult.code, options.context);
2274
+ }
2275
+ return {
2276
+ ...bundleResult,
2277
+ html,
2278
+ hydrationScript,
2279
+ metrics: {
2280
+ ...bundleResult.metrics,
2281
+ totalTime: performance.now() - startTime
2282
+ },
2283
+ ssrMetrics: {
2284
+ renderTime
2285
+ }
2286
+ };
2287
+ }
2288
+ /**
2289
+ * Bundle and execute code, returning the exports.
2290
+ *
2291
+ * @param options - Bundle options
2292
+ * @param context - Execution context
2293
+ * @returns Exported value
2294
+ */
2295
+ async bundleAndExecute(options, context) {
2296
+ const result = await this.bundle({
2297
+ ...options,
2298
+ format: "cjs"
2299
+ // CommonJS for execution
2300
+ });
2301
+ let React;
2302
+ try {
2303
+ React = await import("react");
2304
+ } catch {
2305
+ }
2306
+ return executeDefault(result.code, {
2307
+ React,
2308
+ globals: context,
2309
+ security: mergePolicy(options.security ?? this.defaultSecurity)
2310
+ });
2311
+ }
2312
+ /**
2313
+ * Bundle a component to a self-contained static HTML document.
2314
+ *
2315
+ * Creates a complete HTML page with:
2316
+ * - React runtime (CDN or inline based on platform)
2317
+ * - FrontMCP UI hooks and components (always inline)
2318
+ * - Tool data injection (input/output)
2319
+ * - Transpiled component code
2320
+ * - Client-side rendering via createRoot
2321
+ *
2322
+ * @param options - Static HTML options
2323
+ * @returns Static HTML result with complete document
2324
+ *
2325
+ * @example
2326
+ * ```typescript
2327
+ * const result = await bundler.bundleToStaticHTML({
2328
+ * source: `
2329
+ * import { Card, useToolOutput } from '@frontmcp/ui/react';
2330
+ * export default function Weather() {
2331
+ * const output = useToolOutput();
2332
+ * return <Card title="Weather">{output?.temperature}°F</Card>;
2333
+ * }
2334
+ * `,
2335
+ * toolName: 'get_weather',
2336
+ * output: { temperature: 72 },
2337
+ * });
2338
+ *
2339
+ * // result.html contains the complete HTML document
2340
+ * ```
2341
+ */
2342
+ async bundleToStaticHTML(options) {
2343
+ const startTime = performance.now();
2344
+ const opts = this.mergeStaticHTMLOptions(options);
2345
+ const platform = opts.targetPlatform === "auto" ? "generic" : opts.targetPlatform;
2346
+ const cdnType = getCdnTypeForPlatform(platform);
2347
+ if (opts.universal) {
2348
+ return this.bundleToStaticHTMLUniversal(options, opts, platform, cdnType, startTime);
2349
+ }
2350
+ const bundleResult = await this.bundle({
2351
+ source: options.source,
2352
+ sourceType: opts.sourceType,
2353
+ format: "cjs",
2354
+ minify: opts.minify,
2355
+ sourceMaps: false,
2356
+ externals: ["react", "react-dom", "react/jsx-runtime", "@frontmcp/ui", "@frontmcp/ui/react"],
2357
+ security: opts.security,
2358
+ skipCache: opts.skipCache
2359
+ });
2360
+ const head = this.buildStaticHTMLHead({ externals: opts.externals, customCss: opts.customCss });
2361
+ const reactRuntime = this.buildReactRuntimeScripts(opts.externals, platform, cdnType);
2362
+ const frontmcpRuntime = this.buildFrontMCPRuntime();
2363
+ const dataScript = this.buildDataInjectionScript(opts.toolName, opts.input, opts.output, opts.structuredContent);
2364
+ const componentScript = this.buildComponentRenderScript(bundleResult.code, opts.rootId, cdnType);
2365
+ const html = this.assembleStaticHTML({
2366
+ title: opts.title || `${opts.toolName} - Widget`,
2367
+ head,
2368
+ reactRuntime,
2369
+ frontmcpRuntime,
2370
+ dataScript,
2371
+ componentScript,
2372
+ rootId: opts.rootId,
2373
+ cdnType
2374
+ });
2375
+ const hash = hashContent(html);
2376
+ return {
2377
+ html,
2378
+ componentCode: bundleResult.code,
2379
+ metrics: {
2380
+ ...bundleResult.metrics,
2381
+ totalTime: performance.now() - startTime
2382
+ },
2383
+ hash,
2384
+ size: html.length,
2385
+ cached: bundleResult.cached,
2386
+ sourceType: bundleResult.sourceType,
2387
+ targetPlatform: platform
2388
+ };
2389
+ }
2390
+ /**
2391
+ * Bundle to static HTML with universal rendering mode.
2392
+ * Uses the universal renderer that can handle multiple content types.
2393
+ *
2394
+ * Optimization: Uses cached runtime (vendor chunk) to avoid rebuilding
2395
+ * static code on every request. Only the user's component is transpiled.
2396
+ */
2397
+ async bundleToStaticHTMLUniversal(options, opts, platform, cdnType, startTime) {
2398
+ let contentType;
2399
+ const rawContentType = options.contentType ?? "auto";
2400
+ if (rawContentType === "auto") {
2401
+ contentType = detectContentType(options.source);
2402
+ } else {
2403
+ contentType = rawContentType;
2404
+ }
2405
+ let transpiledCode = null;
2406
+ let transformTime = 0;
2407
+ if (contentType === "react") {
2408
+ const bundleResult = await this.bundle({
2409
+ source: options.source,
2410
+ sourceType: opts.sourceType,
2411
+ format: "cjs",
2412
+ minify: opts.minify,
2413
+ sourceMaps: false,
2414
+ externals: ["react", "react-dom", "react/jsx-runtime", "@frontmcp/ui", "@frontmcp/ui/react"],
2415
+ security: opts.security,
2416
+ skipCache: opts.skipCache
2417
+ });
2418
+ transpiledCode = bundleResult.code;
2419
+ transformTime = bundleResult.metrics.transformTime;
2420
+ }
2421
+ const cachedRuntime = getCachedRuntime({
2422
+ cdnType,
2423
+ includeMarkdown: opts.includeMarkdown || contentType === "markdown",
2424
+ includeMdx: opts.includeMdx || contentType === "mdx",
2425
+ minify: opts.minify
2426
+ });
2427
+ const componentCodeStr = transpiledCode ? buildComponentCode(transpiledCode) : "";
2428
+ const dataInjectionStr = buildDataInjectionCode(
2429
+ opts.toolName,
2430
+ opts.input,
2431
+ opts.output,
2432
+ opts.structuredContent,
2433
+ contentType,
2434
+ transpiledCode ? null : options.source,
2435
+ // Pass source only if not a component
2436
+ transpiledCode !== null
2437
+ );
2438
+ const appScript = buildAppScript(
2439
+ cachedRuntime.appTemplate,
2440
+ componentCodeStr,
2441
+ dataInjectionStr,
2442
+ opts.customComponents ?? ""
2443
+ );
2444
+ const head = this.buildStaticHTMLHead({ externals: opts.externals, customCss: opts.customCss });
2445
+ const reactRuntime = this.buildReactRuntimeScripts(opts.externals, platform, cdnType);
2446
+ const renderScript = this.buildUniversalRenderScript(opts.rootId, cdnType);
2447
+ const html = this.assembleUniversalStaticHTMLCached({
2448
+ title: opts.title || `${opts.toolName} - Widget`,
2449
+ head,
2450
+ reactRuntime,
2451
+ cdnImports: cachedRuntime.cdnImports,
2452
+ vendorScript: cachedRuntime.vendorScript,
2453
+ appScript,
2454
+ renderScript,
2455
+ rootId: opts.rootId,
2456
+ cdnType
2457
+ });
2458
+ const hash = hashContent(html);
2459
+ return {
2460
+ html,
2461
+ componentCode: transpiledCode ?? appScript,
2462
+ metrics: {
2463
+ transformTime,
2464
+ bundleTime: 0,
2465
+ totalTime: performance.now() - startTime,
2466
+ cacheTime: cachedRuntime.cached ? 0 : void 0
2467
+ },
2468
+ hash,
2469
+ size: html.length,
2470
+ cached: cachedRuntime.cached,
2471
+ sourceType: opts.sourceType === "auto" ? this.detectSourceType(options.source) : opts.sourceType,
2472
+ targetPlatform: platform,
2473
+ universal: true,
2474
+ contentType
2475
+ };
2476
+ }
2477
+ /**
2478
+ * Assemble the complete universal static HTML document using cached runtime.
2479
+ *
2480
+ * For ESM mode (OpenAI), scripts must wait for React to load asynchronously.
2481
+ * For UMD mode (Claude), scripts can execute synchronously.
2482
+ */
2483
+ assembleUniversalStaticHTMLCached(parts) {
2484
+ if (parts.cdnType === "umd") {
2485
+ return `<!DOCTYPE html>
2486
+ <html lang="en">
2487
+ <head>
2488
+ <title>${escapeHtml(parts.title)}</title>
2489
+ ${parts.head}
2490
+ ${parts.reactRuntime}
2491
+ ${parts.cdnImports}
2492
+ <!-- Vendor Runtime (Cached) -->
2493
+ <script>
2494
+ ${parts.vendorScript}
2495
+ </script>
2496
+ <!-- App Script (User Component) -->
2497
+ <script>
2498
+ ${parts.appScript}
2499
+ </script>
2500
+ </head>
2501
+ <body>
2502
+ <div id="${parts.rootId}" class="frontmcp-loading">
2503
+ <div class="frontmcp-spinner"></div>
2504
+ </div>
2505
+ ${parts.renderScript}
2506
+ </body>
2507
+ </html>`;
2508
+ } else {
2509
+ return `<!DOCTYPE html>
2510
+ <html lang="en">
2511
+ <head>
2512
+ <title>${escapeHtml(parts.title)}</title>
2513
+ ${parts.head}
2514
+ ${parts.reactRuntime}
2515
+ ${parts.cdnImports}
2516
+ </head>
2517
+ <body>
2518
+ <div id="${parts.rootId}" class="frontmcp-loading">
2519
+ <div class="frontmcp-spinner"></div>
2520
+ </div>
2521
+ <!-- Scripts wait for React to load (ESM is async) -->
2522
+ <script type="module">
2523
+ // Wait for React to be ready
2524
+ function initFrontMCP() {
2525
+ // Vendor Runtime (Cached)
2526
+ ${parts.vendorScript}
2527
+
2528
+ // App Script (User Component)
2529
+ ${parts.appScript}
2530
+
2531
+ // Render the app
2532
+ var container = document.getElementById('${parts.rootId}');
2533
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2534
+ var root = window.ReactDOM.createRoot(container);
2535
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2536
+ }
2537
+ }
2538
+
2539
+ if (window.__reactReady) {
2540
+ initFrontMCP();
2541
+ } else {
2542
+ window.addEventListener('react:ready', initFrontMCP);
2543
+ }
2544
+ </script>
2545
+ </body>
2546
+ </html>`;
2547
+ }
2548
+ }
2549
+ /**
2550
+ * Build the component script for transpiled React/MDX content.
2551
+ * Wraps CommonJS code with module/exports shim to capture the component.
2552
+ */
2553
+ buildUniversalComponentScript(transpiledCode, cdnType) {
2554
+ const wrappedCode = `
2555
+ // CommonJS module shim
2556
+ var module = { exports: {} };
2557
+ var exports = module.exports;
2558
+
2559
+ // Execute transpiled component code (CommonJS format)
2560
+ ${transpiledCode}
2561
+
2562
+ // Capture the component export
2563
+ window.__frontmcp_component = module.exports.default || module.exports;
2564
+ `;
2565
+ if (cdnType === "umd") {
2566
+ return `
2567
+ <!-- Universal Component Script (transpiled) -->
2568
+ <script>
2569
+ (function() {
2570
+ ${wrappedCode}
2571
+ })();
2572
+ </script>`;
2573
+ } else {
2574
+ return `
2575
+ <!-- Universal Component Script (transpiled, ESM) -->
2576
+ <script type="module">
2577
+ function loadComponent() {
2578
+ ${wrappedCode}
2579
+ }
2580
+
2581
+ if (window.__reactReady) {
2582
+ loadComponent();
2583
+ } else {
2584
+ window.addEventListener('react:ready', loadComponent);
2585
+ }
2586
+ </script>`;
2587
+ }
2588
+ }
2589
+ /**
2590
+ * Build the universal runtime script section.
2591
+ */
2592
+ buildUniversalRuntimeScript(runtimeScript) {
2593
+ return `
2594
+ <!-- Universal Runtime -->
2595
+ <script>
2596
+ ${runtimeScript}
2597
+ </script>`;
2598
+ }
2599
+ /**
2600
+ * Build data injection script for universal mode.
2601
+ */
2602
+ buildUniversalDataScript(toolName, input, output, structuredContent, contentType, source, hasTranspiledComponent = false) {
2603
+ const safeJson = (value) => {
2604
+ try {
2605
+ return JSON.stringify(value);
2606
+ } catch {
2607
+ return "null";
2608
+ }
2609
+ };
2610
+ if (hasTranspiledComponent) {
2611
+ return `
2612
+ <!-- Universal Data Injection (React Component) -->
2613
+ <script>
2614
+ window.__frontmcp.setState({
2615
+ toolName: ${safeJson(toolName)},
2616
+ input: ${safeJson(input ?? null)},
2617
+ output: ${safeJson(output ?? null)},
2618
+ structuredContent: ${safeJson(structuredContent ?? null)},
2619
+ content: {
2620
+ type: 'react',
2621
+ source: window.__frontmcp_component
2622
+ },
2623
+ loading: false,
2624
+ error: null
2625
+ });
2626
+ </script>`;
2627
+ }
2628
+ const escapedSource = JSON.stringify(source);
2629
+ return `
2630
+ <!-- Universal Data Injection -->
2631
+ <script>
2632
+ window.__frontmcp.setState({
2633
+ toolName: ${safeJson(toolName)},
2634
+ input: ${safeJson(input ?? null)},
2635
+ output: ${safeJson(output ?? null)},
2636
+ structuredContent: ${safeJson(structuredContent ?? null)},
2637
+ content: {
2638
+ type: ${safeJson(contentType)},
2639
+ source: ${escapedSource}
2640
+ },
2641
+ loading: false,
2642
+ error: null
2643
+ });
2644
+ </script>`;
2645
+ }
2646
+ /**
2647
+ * Build the universal render script.
2648
+ */
2649
+ buildUniversalRenderScript(rootId, cdnType) {
2650
+ if (cdnType === "umd") {
2651
+ return `
2652
+ <!-- Universal Render Script (UMD - synchronous) -->
2653
+ <script>
2654
+ (function() {
2655
+ var container = document.getElementById('${rootId}');
2656
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2657
+ var root = window.ReactDOM.createRoot(container);
2658
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2659
+ } else if (container && window.ReactDOM && window.ReactDOM.render && window.__frontmcp.UniversalApp) {
2660
+ window.ReactDOM.render(
2661
+ React.createElement(window.__frontmcp.UniversalApp),
2662
+ container
2663
+ );
2664
+ }
2665
+ })();
2666
+ </script>`;
2667
+ } else {
2668
+ return `
2669
+ <!-- Universal Render Script (ESM - waits for React) -->
2670
+ <script type="module">
2671
+ function renderUniversalApp() {
2672
+ var container = document.getElementById('${rootId}');
2673
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2674
+ var root = window.ReactDOM.createRoot(container);
2675
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2676
+ }
2677
+ }
2678
+
2679
+ if (window.__reactReady) {
2680
+ renderUniversalApp();
2681
+ } else {
2682
+ window.addEventListener('react:ready', renderUniversalApp);
2683
+ }
2684
+ </script>`;
2685
+ }
2686
+ }
2687
+ /**
2688
+ * Assemble the complete universal static HTML document.
2689
+ */
2690
+ assembleUniversalStaticHTML(parts) {
2691
+ return `<!DOCTYPE html>
2692
+ <html lang="en">
2693
+ <head>
2694
+ <title>${escapeHtml(parts.title)}</title>
2695
+ ${parts.head}
2696
+ ${parts.reactRuntime}
2697
+ ${parts.frontmcpRuntime ?? ""}
2698
+ ${parts.cdnImports}
2699
+ ${parts.universalRuntimeScript}
2700
+ ${parts.componentScript ?? ""}
2701
+ ${parts.dataScript}
2702
+ </head>
2703
+ <body>
2704
+ <div id="${parts.rootId}" class="frontmcp-loading">
2705
+ <div class="frontmcp-spinner"></div>
2706
+ </div>
2707
+ ${parts.renderScript}
2708
+ </body>
2709
+ </html>`;
2710
+ }
2711
+ /**
2712
+ * Get cache statistics.
2713
+ */
2714
+ getCacheStats() {
2715
+ return this.cache.getStats();
2716
+ }
2717
+ /**
2718
+ * Clear the cache.
2719
+ */
2720
+ clearCache() {
2721
+ this.cache.clear();
2722
+ }
2723
+ /**
2724
+ * Clean up expired cache entries.
2725
+ */
2726
+ cleanupCache() {
2727
+ return this.cache.cleanup();
2728
+ }
2729
+ /**
2730
+ * Transform source code using esbuild/SWC.
2731
+ */
2732
+ async transform(source, sourceType, options) {
2733
+ const transform = await loadEsbuild();
2734
+ if (!transform) {
2735
+ throw new Error("No bundler available. Install esbuild or @swc/core: npm install esbuild");
2736
+ }
2737
+ const loader = this.getLoader(sourceType);
2738
+ const esbuildOptions = {
2739
+ loader,
2740
+ minify: options.minify,
2741
+ sourcemap: options.sourceMaps,
2742
+ target: options.target,
2743
+ format: options.format === "cjs" ? "cjs" : options.format === "esm" ? "esm" : "iife",
2744
+ jsx: "automatic",
2745
+ jsxImportSource: options.jsx.importSource
2746
+ };
2747
+ try {
2748
+ const result = await transform(source, esbuildOptions);
2749
+ return {
2750
+ code: result.code,
2751
+ map: result.map
2752
+ };
2753
+ } catch (error) {
2754
+ throw new Error(`Transform failed: ${error instanceof Error ? error.message : String(error)}`);
2755
+ }
2756
+ }
2757
+ /**
2758
+ * Get esbuild loader for source type.
2759
+ */
2760
+ getLoader(sourceType) {
2761
+ switch (sourceType) {
2762
+ case "jsx":
2763
+ return "jsx";
2764
+ case "tsx":
2765
+ return "tsx";
2766
+ case "mdx":
2767
+ return "tsx";
2768
+ // MDX compiles to JSX/TSX
2769
+ case "html":
2770
+ return "text";
2771
+ default:
2772
+ return "tsx";
2773
+ }
2774
+ }
2775
+ /**
2776
+ * Detect source type from content.
2777
+ */
2778
+ detectSourceType(source) {
2779
+ const hasTypeScript = /:\s*(string|number|boolean|any|unknown|void|never|object)\b/.test(source) || /interface\s+\w+/.test(source) || /type\s+\w+\s*=/.test(source) || /<\w+>/.test(source);
2780
+ const hasJSX = /<[A-Z][a-zA-Z]*/.test(source) || // Component tags
2781
+ /<[a-z]+\s/.test(source) || // HTML tags with attributes
2782
+ /<[a-z]+>/.test(source) || // Self-closing HTML tags
2783
+ /<\/[a-z]+>/.test(source);
2784
+ const hasMDX = /^#\s+/.test(source) || // Markdown heading
2785
+ /^-\s+/.test(source) || // Markdown list
2786
+ /\*\*\w+\*\*/.test(source) || // Bold
2787
+ /```\w*\n/.test(source);
2788
+ if (hasMDX && hasJSX) {
2789
+ return "mdx";
2790
+ }
2791
+ if (hasTypeScript && hasJSX) {
2792
+ return "tsx";
2793
+ }
2794
+ if (hasJSX) {
2795
+ return "jsx";
2796
+ }
2797
+ if (hasTypeScript) {
2798
+ return "tsx";
2799
+ }
2800
+ return "jsx";
2801
+ }
2802
+ /**
2803
+ * Merge bundle options with defaults.
2804
+ */
2805
+ mergeOptions(options) {
2806
+ return {
2807
+ sourceType: options.sourceType ?? DEFAULT_BUNDLE_OPTIONS.sourceType,
2808
+ format: options.format ?? DEFAULT_BUNDLE_OPTIONS.format,
2809
+ minify: options.minify ?? DEFAULT_BUNDLE_OPTIONS.minify,
2810
+ sourceMaps: options.sourceMaps ?? DEFAULT_BUNDLE_OPTIONS.sourceMaps,
2811
+ externals: options.externals ?? DEFAULT_BUNDLE_OPTIONS.externals,
2812
+ jsx: {
2813
+ ...DEFAULT_BUNDLE_OPTIONS.jsx,
2814
+ ...options.jsx
2815
+ },
2816
+ target: options.target ?? DEFAULT_BUNDLE_OPTIONS.target,
2817
+ globalName: options.globalName ?? DEFAULT_BUNDLE_OPTIONS.globalName,
2818
+ skipCache: options.skipCache ?? DEFAULT_BUNDLE_OPTIONS.skipCache
2819
+ };
2820
+ }
2821
+ /**
2822
+ * Build hydration script for client-side React.
2823
+ */
2824
+ buildHydrationScript(bundledCode, context) {
2825
+ const contextJson = context ? JSON.stringify(context) : "{}";
2826
+ return `
2827
+ (function() {
2828
+ var context = ${contextJson};
2829
+ var exports = {};
2830
+ var module = { exports: exports };
2831
+
2832
+ // Execute bundled code
2833
+ (function(exports, module) {
2834
+ ${bundledCode}
2835
+ })(exports, module);
2836
+
2837
+ // Get component
2838
+ var Component = module.exports.default || module.exports;
2839
+
2840
+ // Hydrate
2841
+ if (typeof ReactDOM !== 'undefined' && ReactDOM.hydrateRoot) {
2842
+ var container = document.getElementById('root') || document.body.firstElementChild;
2843
+ if (container) {
2844
+ ReactDOM.hydrateRoot(container, React.createElement(Component, context));
2845
+ }
2846
+ }
2847
+ })();
2848
+ `.trim();
2849
+ }
2850
+ // ============================================
2851
+ // Static HTML Helper Methods
2852
+ // ============================================
2853
+ /**
2854
+ * Merge static HTML options with defaults.
2855
+ */
2856
+ mergeStaticHTMLOptions(options) {
2857
+ return {
2858
+ sourceType: options.sourceType ?? DEFAULT_STATIC_HTML_OPTIONS.sourceType,
2859
+ targetPlatform: options.targetPlatform ?? DEFAULT_STATIC_HTML_OPTIONS.targetPlatform,
2860
+ minify: options.minify ?? DEFAULT_STATIC_HTML_OPTIONS.minify,
2861
+ skipCache: options.skipCache ?? DEFAULT_STATIC_HTML_OPTIONS.skipCache,
2862
+ rootId: sanitizeRootId(options.rootId ?? DEFAULT_STATIC_HTML_OPTIONS.rootId),
2863
+ widgetAccessible: options.widgetAccessible ?? DEFAULT_STATIC_HTML_OPTIONS.widgetAccessible,
2864
+ externals: {
2865
+ ...DEFAULT_STATIC_HTML_OPTIONS.externals,
2866
+ ...options.externals
2867
+ },
2868
+ // Universal mode options
2869
+ universal: options.universal ?? DEFAULT_STATIC_HTML_OPTIONS.universal,
2870
+ contentType: options.contentType ?? DEFAULT_STATIC_HTML_OPTIONS.contentType,
2871
+ includeMarkdown: options.includeMarkdown ?? DEFAULT_STATIC_HTML_OPTIONS.includeMarkdown,
2872
+ includeMdx: options.includeMdx ?? DEFAULT_STATIC_HTML_OPTIONS.includeMdx,
2873
+ // Pass-through options
2874
+ toolName: options.toolName,
2875
+ input: options.input,
2876
+ output: options.output,
2877
+ structuredContent: options.structuredContent,
2878
+ title: options.title,
2879
+ security: options.security,
2880
+ customCss: options.customCss,
2881
+ customComponents: options.customComponents
2882
+ };
2883
+ }
2884
+ /**
2885
+ * Build the <head> section for static HTML.
2886
+ */
2887
+ buildStaticHTMLHead(opts) {
2888
+ const parts = [];
2889
+ parts.push(`<meta charset="UTF-8">`);
2890
+ parts.push(`<meta name="viewport" content="width=device-width, initial-scale=1.0">`);
2891
+ for (const url of STATIC_HTML_CDN.fonts.preconnect) {
2892
+ parts.push(`<link rel="preconnect" href="${url}" crossorigin>`);
2893
+ }
2894
+ parts.push(`<link rel="stylesheet" href="${STATIC_HTML_CDN.fonts.inter}">`);
2895
+ const tailwindConfig = opts.externals.tailwind ?? "cdn";
2896
+ if (tailwindConfig === "cdn") {
2897
+ parts.push(`<link rel="stylesheet" href="${STATIC_HTML_CDN.tailwind}">`);
2898
+ } else if (tailwindConfig !== "inline" && tailwindConfig) {
2899
+ parts.push(`<link rel="stylesheet" href="${tailwindConfig}">`);
2900
+ }
2901
+ parts.push(`<style>
2902
+ body { margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
2903
+ .frontmcp-loading { display: flex; align-items: center; justify-content: center; min-height: 200px; }
2904
+ .frontmcp-spinner { width: 24px; height: 24px; border: 2px solid #e5e7eb; border-top-color: #3b82f6; border-radius: 50%; animation: spin 1s linear infinite; }
2905
+ @keyframes spin { to { transform: rotate(360deg); } }
2906
+ </style>`);
2907
+ if (opts.customCss) {
2908
+ parts.push(`<style>
2909
+ ${sanitizeCss(opts.customCss)}
2910
+ </style>`);
2911
+ }
2912
+ return parts.join("\n ");
2913
+ }
2914
+ /**
2915
+ * Build React runtime scripts for static HTML.
2916
+ */
2917
+ buildReactRuntimeScripts(externals, platform, cdnType) {
2918
+ const reactConfig = externals.react ?? "cdn";
2919
+ const reactDomConfig = externals.reactDom ?? "cdn";
2920
+ if (cdnType === "umd") {
2921
+ const reactUrl = reactConfig === "cdn" ? STATIC_HTML_CDN.umd.react : reactConfig;
2922
+ const reactDomUrl = reactDomConfig === "cdn" ? STATIC_HTML_CDN.umd.reactDom : reactDomConfig;
2923
+ return `
2924
+ <!-- React Runtime (UMD from cdnjs - Claude compatible) -->
2925
+ <script src="${reactUrl}"></script>
2926
+ <script src="${reactDomUrl}"></script>
2927
+ <script>
2928
+ // Webpack/esbuild polyfills for transpiled code (UMD globals)
2929
+ window.external_react_namespaceObject = window.React;
2930
+ window.jsx_runtime_namespaceObject = {
2931
+ jsx: function(type, props, key) {
2932
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2933
+ return React.createElement(type, props);
2934
+ },
2935
+ jsxs: function(type, props, key) {
2936
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2937
+ return React.createElement(type, props);
2938
+ },
2939
+ Fragment: React.Fragment
2940
+ };
2941
+ window.__reactReady = true;
2942
+ </script>`;
2943
+ } else {
2944
+ const reactUrl = reactConfig === "cdn" ? STATIC_HTML_CDN.esm.react : reactConfig;
2945
+ const reactDomUrl = reactDomConfig === "cdn" ? STATIC_HTML_CDN.esm.reactDom : reactDomConfig;
2946
+ return `
2947
+ <!-- React Runtime (ES modules from esm.sh) -->
2948
+ <script type="module">
2949
+ import React from '${reactUrl}';
2950
+ import { createRoot } from '${reactDomUrl}';
2951
+
2952
+ // Make React available globally
2953
+ window.React = React;
2954
+ window.ReactDOM = { createRoot };
2955
+
2956
+ // Webpack/esbuild polyfills for transpiled code
2957
+ window.external_react_namespaceObject = React;
2958
+ window.jsx_runtime_namespaceObject = {
2959
+ jsx: function(type, props, key) {
2960
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2961
+ return React.createElement(type, props);
2962
+ },
2963
+ jsxs: function(type, props, key) {
2964
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2965
+ return React.createElement(type, props);
2966
+ },
2967
+ Fragment: React.Fragment
2968
+ };
2969
+
2970
+ // Signal React is ready
2971
+ window.__reactReady = true;
2972
+ window.dispatchEvent(new CustomEvent('react:ready'));
2973
+ </script>`;
2974
+ }
2975
+ }
2976
+ /**
2977
+ * Build FrontMCP runtime (hooks and UI components).
2978
+ * Always inlined for reliability across platforms.
2979
+ */
2980
+ buildFrontMCPRuntime() {
2981
+ return `
2982
+ <!-- FrontMCP Runtime (always inline) -->
2983
+ <script>
2984
+ // Custom require() shim for browser - maps module names to globals
2985
+ // This allows esbuild-transpiled code to work in browsers
2986
+ window.__moduleCache = {};
2987
+ window.require = function(moduleName) {
2988
+ // Check cache first
2989
+ if (window.__moduleCache[moduleName]) {
2990
+ return window.__moduleCache[moduleName];
2991
+ }
2992
+
2993
+ // Map module names to browser globals
2994
+ var moduleMap = {
2995
+ 'react': function() { return window.React; },
2996
+ 'react-dom': function() { return window.ReactDOM; },
2997
+ 'react-dom/client': function() { return window.ReactDOM; },
2998
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
2999
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
3000
+ '@frontmcp/ui': function() { return window.react_namespaceObject; },
3001
+ '@frontmcp/ui/react': function() { return window.react_namespaceObject; },
3002
+ };
3003
+
3004
+ var resolver = moduleMap[moduleName];
3005
+ if (resolver) {
3006
+ var mod = resolver();
3007
+ window.__moduleCache[moduleName] = mod;
3008
+ return mod;
3009
+ }
3010
+
3011
+ console.warn('[FrontMCP] Unknown module requested:', moduleName);
3012
+ return {};
3013
+ };
3014
+
3015
+ // Async require for dynamic imports (returns Promise)
3016
+ window.requireAsync = function(moduleName) {
3017
+ return new Promise(function(resolve, reject) {
3018
+ // If module is already loaded, resolve immediately
3019
+ var mod = window.require(moduleName);
3020
+ if (mod && Object.keys(mod).length > 0) {
3021
+ resolve(mod);
3022
+ return;
3023
+ }
3024
+
3025
+ // For now, we don't support dynamic CDN loading
3026
+ // All required modules should be pre-loaded
3027
+ console.warn('[FrontMCP] Async module not available:', moduleName);
3028
+ resolve({});
3029
+ });
3030
+ };
3031
+
3032
+ // FrontMCP Hook implementations
3033
+ window.__frontmcp = {
3034
+ // Context for MCP bridge
3035
+ context: {
3036
+ toolName: null,
3037
+ toolInput: null,
3038
+ toolOutput: null,
3039
+ structuredContent: null,
3040
+ callTool: null,
3041
+ },
3042
+
3043
+ // Set context from data injection
3044
+ setContext: function(ctx) {
3045
+ Object.assign(this.context, ctx);
3046
+ },
3047
+ };
3048
+
3049
+ // Hook: useToolOutput - returns the tool output data
3050
+ window.useToolOutput = function() {
3051
+ return window.__frontmcp.context.toolOutput;
3052
+ };
3053
+
3054
+ // Hook: useToolInput - returns the tool input arguments
3055
+ window.useToolInput = function() {
3056
+ return window.__frontmcp.context.toolInput;
3057
+ };
3058
+
3059
+ // Hook: useMcpBridgeContext - returns full bridge context
3060
+ window.useMcpBridgeContext = function() {
3061
+ return window.__frontmcp.context;
3062
+ };
3063
+
3064
+ // Hook: useCallTool - returns function to call other tools
3065
+ window.useCallTool = function() {
3066
+ return function(name, args) {
3067
+ if (window.__frontmcp.context.callTool) {
3068
+ return window.__frontmcp.context.callTool(name, args);
3069
+ }
3070
+ console.warn('[FrontMCP] callTool not available - widget may not have tool access');
3071
+ return Promise.resolve(null);
3072
+ };
3073
+ };
3074
+
3075
+ // UI Components (simplified inline versions)
3076
+ window.Card = function(props) {
3077
+ var children = props.children;
3078
+ var title = props.title;
3079
+ var className = props.className || '';
3080
+ return React.createElement('div', {
3081
+ className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
3082
+ }, [
3083
+ title && React.createElement('div', {
3084
+ key: 'header',
3085
+ className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
3086
+ }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
3087
+ React.createElement('div', { key: 'body', className: 'p-4' }, children)
3088
+ ]);
3089
+ };
3090
+
3091
+ window.Badge = function(props) {
3092
+ var children = props.children;
3093
+ var variant = props.variant || 'default';
3094
+ var variantClasses = {
3095
+ default: 'bg-gray-100 text-gray-800',
3096
+ success: 'bg-green-100 text-green-800',
3097
+ warning: 'bg-yellow-100 text-yellow-800',
3098
+ error: 'bg-red-100 text-red-800',
3099
+ info: 'bg-blue-100 text-blue-800',
3100
+ };
3101
+ return React.createElement('span', {
3102
+ className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
3103
+ }, children);
3104
+ };
3105
+
3106
+ window.Button = function(props) {
3107
+ var children = props.children;
3108
+ var variant = props.variant || 'primary';
3109
+ var onClick = props.onClick;
3110
+ var disabled = props.disabled;
3111
+ var variantClasses = {
3112
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
3113
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
3114
+ outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
3115
+ danger: 'bg-red-600 text-white hover:bg-red-700',
3116
+ };
3117
+ return React.createElement('button', {
3118
+ className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
3119
+ (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
3120
+ (variantClasses[variant] || variantClasses.primary),
3121
+ onClick: onClick,
3122
+ disabled: disabled,
3123
+ }, children);
3124
+ };
3125
+
3126
+ // Make hooks available on react_namespaceObject for bundled imports
3127
+ window.react_namespaceObject = Object.assign({}, window.React || {}, {
3128
+ useToolOutput: window.useToolOutput,
3129
+ useToolInput: window.useToolInput,
3130
+ useMcpBridgeContext: window.useMcpBridgeContext,
3131
+ useCallTool: window.useCallTool,
3132
+ Card: window.Card,
3133
+ Badge: window.Badge,
3134
+ Button: window.Button,
3135
+ });
3136
+ </script>`;
3137
+ }
3138
+ /**
3139
+ * Build data injection script for tool input/output.
3140
+ */
3141
+ buildDataInjectionScript(toolName, input, output, structuredContent) {
3142
+ const safeJson = (value) => {
3143
+ try {
3144
+ return JSON.stringify(value);
3145
+ } catch {
3146
+ return "null";
3147
+ }
3148
+ };
3149
+ return `
3150
+ <!-- Tool Data Injection -->
3151
+ <script>
3152
+ window.__mcpToolName = ${safeJson(toolName)};
3153
+ window.__mcpToolInput = ${safeJson(input ?? null)};
3154
+ window.__mcpToolOutput = ${safeJson(output ?? null)};
3155
+ window.__mcpStructuredContent = ${safeJson(structuredContent ?? null)};
3156
+
3157
+ // Initialize FrontMCP context
3158
+ window.__frontmcp.setContext({
3159
+ toolName: window.__mcpToolName,
3160
+ toolInput: window.__mcpToolInput,
3161
+ toolOutput: window.__mcpToolOutput,
3162
+ structuredContent: window.__mcpStructuredContent,
3163
+ });
3164
+ </script>`;
3165
+ }
3166
+ /**
3167
+ * Build component render script.
3168
+ * Wraps CommonJS code with module/exports shim to capture the component.
3169
+ */
3170
+ buildComponentRenderScript(componentCode, rootId, cdnType) {
3171
+ const wrappedCode = `
3172
+ // CommonJS module shim
3173
+ var module = { exports: {} };
3174
+ var exports = module.exports;
3175
+
3176
+ // Execute transpiled component code (CommonJS format)
3177
+ ${componentCode}
3178
+
3179
+ // Capture the component export
3180
+ window.__frontmcp_component = module.exports;
3181
+ `;
3182
+ if (cdnType === "umd") {
3183
+ return `
3184
+ <!-- Component Render Script (UMD - synchronous) -->
3185
+ <script>
3186
+ (function() {
3187
+ ${wrappedCode}
3188
+
3189
+ // Get the component
3190
+ var Component = window.__frontmcp_component.default || window.__frontmcp_component;
3191
+
3192
+ // Render the component
3193
+ var container = document.getElementById('${rootId}');
3194
+ if (container && window.ReactDOM && window.ReactDOM.createRoot) {
3195
+ var root = window.ReactDOM.createRoot(container);
3196
+ root.render(React.createElement(Component, {
3197
+ output: window.__mcpToolOutput,
3198
+ input: window.__mcpToolInput,
3199
+ }));
3200
+ } else if (container && window.ReactDOM && window.ReactDOM.render) {
3201
+ // Fallback for React 17
3202
+ window.ReactDOM.render(
3203
+ React.createElement(Component, {
3204
+ output: window.__mcpToolOutput,
3205
+ input: window.__mcpToolInput,
3206
+ }),
3207
+ container
3208
+ );
3209
+ }
3210
+ })();
3211
+ </script>`;
3212
+ } else {
3213
+ return `
3214
+ <!-- Component Render Script (ESM - waits for React) -->
3215
+ <script type="module">
3216
+ function renderComponent() {
3217
+ ${wrappedCode}
3218
+
3219
+ // Get the component
3220
+ var Component = window.__frontmcp_component.default || window.__frontmcp_component;
3221
+
3222
+ // Render the component
3223
+ var container = document.getElementById('${rootId}');
3224
+ if (container && window.ReactDOM && window.ReactDOM.createRoot) {
3225
+ var root = window.ReactDOM.createRoot(container);
3226
+ root.render(React.createElement(Component, {
3227
+ output: window.__mcpToolOutput,
3228
+ input: window.__mcpToolInput,
3229
+ }));
3230
+ }
3231
+ }
3232
+
3233
+ // Wait for React to be ready
3234
+ if (window.__reactReady) {
3235
+ renderComponent();
3236
+ } else {
3237
+ window.addEventListener('react:ready', renderComponent);
3238
+ }
3239
+ </script>`;
3240
+ }
3241
+ }
3242
+ /**
3243
+ * Assemble the complete static HTML document.
3244
+ */
3245
+ assembleStaticHTML(parts) {
3246
+ return `<!DOCTYPE html>
3247
+ <html lang="en">
3248
+ <head>
3249
+ <title>${escapeHtml(parts.title)}</title>
3250
+ ${parts.head}
3251
+ ${parts.reactRuntime}
3252
+ ${parts.frontmcpRuntime}
3253
+ ${parts.dataScript}
3254
+ </head>
3255
+ <body>
3256
+ <div id="${parts.rootId}" class="frontmcp-loading">
3257
+ <div class="frontmcp-spinner"></div>
3258
+ </div>
3259
+ ${parts.componentScript}
3260
+ </body>
3261
+ </html>`;
3262
+ }
3263
+ };
3264
+ function createBundler(options) {
3265
+ return new InMemoryBundler(options);
3266
+ }
3267
+
3268
+ // libs/ui/src/bundler/file-cache/storage/index.ts
3269
+ init_interface();
3270
+ init_filesystem();
3271
+ init_redis();
3272
+
3273
+ // libs/ui/src/bundler/file-cache/hash-calculator.ts
3274
+ var import_crypto2 = require("crypto");
3275
+ var import_promises2 = require("fs/promises");
3276
+ var import_fs2 = require("fs");
3277
+ var import_path2 = require("path");
3278
+ function sha256(content) {
3279
+ return (0, import_crypto2.createHash)("sha256").update(content, "utf8").digest("hex");
3280
+ }
3281
+ function sha256Buffer(buffer) {
3282
+ return (0, import_crypto2.createHash)("sha256").update(buffer).digest("hex");
3283
+ }
3284
+ async function hashFile(filePath) {
3285
+ try {
3286
+ const content = await (0, import_promises2.readFile)(filePath);
3287
+ return sha256Buffer(content);
3288
+ } catch {
3289
+ return void 0;
3290
+ }
3291
+ }
3292
+ async function hashFiles(filePaths) {
3293
+ const hashes = [];
3294
+ for (const filePath of filePaths.sort()) {
3295
+ const hash = await hashFile(filePath);
3296
+ if (hash) {
3297
+ hashes.push(`${filePath}:${hash}`);
3298
+ }
3299
+ }
3300
+ return sha256(hashes.join("\n"));
3301
+ }
3302
+ async function calculateComponentHash(options) {
3303
+ const {
3304
+ entryPath,
3305
+ baseDir = (0, import_path2.dirname)(entryPath),
3306
+ externals = [],
3307
+ dependencies = {},
3308
+ bundleOptions = {},
3309
+ maxDepth = 10
3310
+ } = options;
3311
+ const absoluteEntryPath = (0, import_path2.resolve)(entryPath);
3312
+ const files = /* @__PURE__ */ new Set();
3313
+ const fileHashes = {};
3314
+ await collectLocalDependencies(absoluteEntryPath, baseDir, files, maxDepth, 0);
3315
+ for (const file of files) {
3316
+ const hash = await hashFile(file);
3317
+ if (hash) {
3318
+ fileHashes[file] = hash;
3319
+ }
3320
+ }
3321
+ const sortedFiles = Array.from(files).sort();
3322
+ const fileHashContent = sortedFiles.map((f) => `${f}:${fileHashes[f] || "missing"}`).join("\n");
3323
+ const filesHash = sha256(fileHashContent);
3324
+ const optionsHash = sha256(JSON.stringify(sortedObject(bundleOptions)));
3325
+ const dependenciesHash = sha256(JSON.stringify(sortedObject(dependencies)));
3326
+ const combinedHash = sha256([filesHash, optionsHash, dependenciesHash].join(":"));
3327
+ return {
3328
+ hash: combinedHash,
3329
+ entryHash: fileHashes[absoluteEntryPath] || "",
3330
+ files: sortedFiles,
3331
+ fileHashes,
3332
+ optionsHash,
3333
+ dependenciesHash
3334
+ };
3335
+ }
3336
+ async function calculateQuickHash(entryPath, bundleOptions) {
3337
+ const entryHash = await hashFile(entryPath);
3338
+ const optionsHash = bundleOptions ? sha256(JSON.stringify(sortedObject(bundleOptions))) : "";
3339
+ return sha256(`${entryHash || "missing"}:${optionsHash}`);
3340
+ }
3341
+ async function collectLocalDependencies(filePath, baseDir, collected, maxDepth, currentDepth) {
3342
+ if (currentDepth >= maxDepth) return;
3343
+ if (collected.has(filePath)) return;
3344
+ if (!(0, import_fs2.existsSync)(filePath)) return;
3345
+ collected.add(filePath);
3346
+ try {
3347
+ const content = await (0, import_promises2.readFile)(filePath, "utf8");
3348
+ const imports = extractImportPaths(content);
3349
+ for (const importPath of imports) {
3350
+ if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
3351
+ continue;
3352
+ }
3353
+ const resolvedPath = resolveImportPath(importPath, (0, import_path2.dirname)(filePath));
3354
+ if (resolvedPath && (0, import_fs2.existsSync)(resolvedPath)) {
3355
+ await collectLocalDependencies(resolvedPath, baseDir, collected, maxDepth, currentDepth + 1);
3356
+ }
3357
+ }
3358
+ } catch {
3359
+ }
3360
+ }
3361
+ function extractImportPaths(source) {
3362
+ const paths = [];
3363
+ const importRegex = /import\s+(?:[^'"]+\s+from\s+)?['"]([^'"]+)['"]/g;
3364
+ let match;
3365
+ while ((match = importRegex.exec(source)) !== null) {
3366
+ paths.push(match[1]);
3367
+ }
3368
+ const exportRegex = /export\s+(?:\*|{[^}]+})\s+from\s+['"]([^'"]+)['"]/g;
3369
+ while ((match = exportRegex.exec(source)) !== null) {
3370
+ paths.push(match[1]);
3371
+ }
3372
+ const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
3373
+ while ((match = requireRegex.exec(source)) !== null) {
3374
+ paths.push(match[1]);
3375
+ }
3376
+ const dynamicRegex = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
3377
+ while ((match = dynamicRegex.exec(source)) !== null) {
3378
+ paths.push(match[1]);
3379
+ }
3380
+ return [...new Set(paths)];
3381
+ }
3382
+ function resolveImportPath(importPath, fromDir) {
3383
+ const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3384
+ for (const ext of extensions) {
3385
+ const fullPath = (0, import_path2.join)(fromDir, importPath + ext);
3386
+ if ((0, import_fs2.existsSync)(fullPath)) {
3387
+ return fullPath;
3388
+ }
3389
+ }
3390
+ for (const ext of extensions) {
3391
+ const indexPath = (0, import_path2.join)(fromDir, importPath, `index${ext}`);
3392
+ if ((0, import_fs2.existsSync)(indexPath)) {
3393
+ return indexPath;
3394
+ }
3395
+ }
3396
+ return void 0;
3397
+ }
3398
+ function sortedObject(obj) {
3399
+ const sorted = {};
3400
+ const keys = Object.keys(obj).sort();
3401
+ for (const key of keys) {
3402
+ const value = obj[key];
3403
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3404
+ sorted[key] = sortedObject(value);
3405
+ } else {
3406
+ sorted[key] = value;
3407
+ }
3408
+ }
3409
+ return sorted;
3410
+ }
3411
+ function generateBuildId() {
3412
+ const timestamp = Date.now().toString(36);
3413
+ const random = Math.random().toString(36).substring(2, 10);
3414
+ return `${timestamp}-${random}`;
3415
+ }
3416
+ function buildIdFromHash(hash) {
3417
+ return hash.substring(0, 12);
3418
+ }
3419
+
3420
+ // libs/ui/src/bundler/file-cache/component-builder.ts
3421
+ var import_promises3 = require("fs/promises");
3422
+ var import_fs3 = require("fs");
3423
+ var import_path3 = require("path");
3424
+ var import_crypto3 = require("crypto");
3425
+
3426
+ // libs/ui/src/dependency/cdn-registry.ts
3427
+ var DEFAULT_CDN_REGISTRY = {
3428
+ // ============================================
3429
+ // React Ecosystem
3430
+ // ============================================
3431
+ react: {
3432
+ packageName: "react",
3433
+ defaultVersion: "18.3.1",
3434
+ providers: {
3435
+ cloudflare: {
3436
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js",
3437
+ integrity: "sha512-Qp8J4Xr8LBZ5CXNJQc/HmLqFrpXz6lNkbzMYkYHKzQx5p1q1yOqPQHntXKoYgPPE/n9m0QF1OkJdXa2ePpO4fw==",
3438
+ global: "React",
3439
+ crossorigin: "anonymous"
3440
+ },
3441
+ jsdelivr: {
3442
+ url: "https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js",
3443
+ global: "React",
3444
+ crossorigin: "anonymous"
3445
+ },
3446
+ unpkg: {
3447
+ url: "https://unpkg.com/react@18.3.1/umd/react.production.min.js",
3448
+ global: "React",
3449
+ crossorigin: "anonymous"
3450
+ },
3451
+ "esm.sh": {
3452
+ url: "https://esm.sh/react@18.3.1",
3453
+ esm: true,
3454
+ crossorigin: "anonymous"
3455
+ }
3456
+ },
3457
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3458
+ metadata: {
3459
+ description: "A JavaScript library for building user interfaces",
3460
+ homepage: "https://react.dev",
3461
+ license: "MIT"
3462
+ }
3463
+ },
3464
+ "react-dom": {
3465
+ packageName: "react-dom",
3466
+ defaultVersion: "18.3.1",
3467
+ providers: {
3468
+ cloudflare: {
3469
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js",
3470
+ integrity: "sha512-6s2gVRdS3aT+FDdZTRJSzKlzIPqDXWyYl/5hPQb6hSgzKPGFcQyZhbqjbWVxGrs2dYNrINFXb0k0UD3d+CKPJA==",
3471
+ global: "ReactDOM",
3472
+ crossorigin: "anonymous",
3473
+ peerDependencies: ["react"]
3474
+ },
3475
+ jsdelivr: {
3476
+ url: "https://cdn.jsdelivr.net/npm/react-dom@18.3.1/umd/react-dom.production.min.js",
3477
+ global: "ReactDOM",
3478
+ crossorigin: "anonymous",
3479
+ peerDependencies: ["react"]
3480
+ },
3481
+ unpkg: {
3482
+ url: "https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js",
3483
+ global: "ReactDOM",
3484
+ crossorigin: "anonymous",
3485
+ peerDependencies: ["react"]
3486
+ },
3487
+ "esm.sh": {
3488
+ url: "https://esm.sh/react-dom@18.3.1",
3489
+ esm: true,
3490
+ crossorigin: "anonymous",
3491
+ peerDependencies: ["react"]
3492
+ }
3493
+ },
3494
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3495
+ metadata: {
3496
+ description: "React package for working with the DOM",
3497
+ homepage: "https://react.dev",
3498
+ license: "MIT"
3499
+ }
3500
+ },
3501
+ // ============================================
3502
+ // Charting Libraries
3503
+ // ============================================
3504
+ "chart.js": {
3505
+ packageName: "chart.js",
3506
+ defaultVersion: "4.4.7",
3507
+ providers: {
3508
+ cloudflare: {
3509
+ url: "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.7/chart.umd.min.js",
3510
+ integrity: "sha512-dMDjIoZjJD6gs0KPBhFYjLQrH3kIohSEn6HzWs6Y6GiO0+L9kk/bM3cR5KNEDK1KvMNpTIZG6pHK9SZfCJHRpQ==",
3511
+ global: "Chart",
3512
+ crossorigin: "anonymous"
3513
+ },
3514
+ jsdelivr: {
3515
+ url: "https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js",
3516
+ global: "Chart",
3517
+ crossorigin: "anonymous"
3518
+ },
3519
+ unpkg: {
3520
+ url: "https://unpkg.com/chart.js@4.4.7/dist/chart.umd.min.js",
3521
+ global: "Chart",
3522
+ crossorigin: "anonymous"
3523
+ }
3524
+ },
3525
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3526
+ metadata: {
3527
+ description: "Simple yet flexible JavaScript charting library",
3528
+ homepage: "https://www.chartjs.org",
3529
+ license: "MIT"
3530
+ }
3531
+ },
3532
+ "react-chartjs-2": {
3533
+ packageName: "react-chartjs-2",
3534
+ defaultVersion: "5.3.0",
3535
+ providers: {
3536
+ cloudflare: {
3537
+ url: "https://cdnjs.cloudflare.com/ajax/libs/react-chartjs-2/5.3.0/react-chartjs-2.min.js",
3538
+ global: "ReactChartjs2",
3539
+ crossorigin: "anonymous",
3540
+ peerDependencies: ["react", "chart.js"]
3541
+ },
3542
+ jsdelivr: {
3543
+ url: "https://cdn.jsdelivr.net/npm/react-chartjs-2@5.3.0/dist/index.umd.js",
3544
+ global: "ReactChartjs2",
3545
+ crossorigin: "anonymous",
3546
+ peerDependencies: ["react", "chart.js"]
3547
+ },
3548
+ "esm.sh": {
3549
+ url: "https://esm.sh/react-chartjs-2@5.3.0",
3550
+ esm: true,
3551
+ crossorigin: "anonymous",
3552
+ peerDependencies: ["react", "chart.js"]
3553
+ }
3554
+ },
3555
+ preferredProviders: ["cloudflare", "jsdelivr", "esm.sh"],
3556
+ metadata: {
3557
+ description: "React components for Chart.js",
3558
+ homepage: "https://react-chartjs-2.js.org",
3559
+ license: "MIT"
3560
+ }
3561
+ },
3562
+ // ============================================
3563
+ // D3.js
3564
+ // ============================================
3565
+ d3: {
3566
+ packageName: "d3",
3567
+ defaultVersion: "7.9.0",
3568
+ providers: {
3569
+ cloudflare: {
3570
+ url: "https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js",
3571
+ integrity: "sha512-vc58qvvBdrDR4etbxMdlTt4GBQk1qjvyORR2nrsPsFPyrs+/u5c3+1Ct6upOgdZoIl7eq6k3a1UPDSNAQi/32A==",
3572
+ global: "d3",
3573
+ crossorigin: "anonymous"
3574
+ },
3575
+ jsdelivr: {
3576
+ url: "https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js",
3577
+ global: "d3",
3578
+ crossorigin: "anonymous"
3579
+ },
3580
+ unpkg: {
3581
+ url: "https://unpkg.com/d3@7.9.0/dist/d3.min.js",
3582
+ global: "d3",
3583
+ crossorigin: "anonymous"
3584
+ }
3585
+ },
3586
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3587
+ metadata: {
3588
+ description: "Data-Driven Documents",
3589
+ homepage: "https://d3js.org",
3590
+ license: "ISC"
3591
+ }
3592
+ },
3593
+ // ============================================
3594
+ // Utility Libraries
3595
+ // ============================================
3596
+ lodash: {
3597
+ packageName: "lodash",
3598
+ defaultVersion: "4.17.21",
3599
+ providers: {
3600
+ cloudflare: {
3601
+ url: "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js",
3602
+ integrity: "sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==",
3603
+ global: "_",
3604
+ crossorigin: "anonymous"
3605
+ },
3606
+ jsdelivr: {
3607
+ url: "https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js",
3608
+ global: "_",
3609
+ crossorigin: "anonymous"
3610
+ },
3611
+ unpkg: {
3612
+ url: "https://unpkg.com/lodash@4.17.21/lodash.min.js",
3613
+ global: "_",
3614
+ crossorigin: "anonymous"
3615
+ }
3616
+ },
3617
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3618
+ metadata: {
3619
+ description: "A modern JavaScript utility library",
3620
+ homepage: "https://lodash.com",
3621
+ license: "MIT"
3622
+ }
3623
+ },
3624
+ "lodash-es": {
3625
+ packageName: "lodash-es",
3626
+ defaultVersion: "4.17.21",
3627
+ providers: {
3628
+ "esm.sh": {
3629
+ url: "https://esm.sh/lodash-es@4.17.21",
3630
+ esm: true,
3631
+ crossorigin: "anonymous"
3632
+ },
3633
+ jsdelivr: {
3634
+ url: "https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm",
3635
+ esm: true,
3636
+ crossorigin: "anonymous"
3637
+ }
3638
+ },
3639
+ preferredProviders: ["esm.sh", "jsdelivr"],
3640
+ metadata: {
3641
+ description: "Lodash exported as ES modules",
3642
+ homepage: "https://lodash.com",
3643
+ license: "MIT"
3644
+ }
3645
+ },
3646
+ dayjs: {
3647
+ packageName: "dayjs",
3648
+ defaultVersion: "1.11.13",
3649
+ providers: {
3650
+ cloudflare: {
3651
+ url: "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.13/dayjs.min.js",
3652
+ integrity: "sha512-Ot7ArUEhJDU0cwoBNNnWe487kjL5wAOsIYig8llY/l0P2TUFwgsAHVmrZMHsT8NGo+HwkjTJsNErS6QqIkBxDw==",
3653
+ global: "dayjs",
3654
+ crossorigin: "anonymous"
3655
+ },
3656
+ jsdelivr: {
3657
+ url: "https://cdn.jsdelivr.net/npm/dayjs@1.11.13/dayjs.min.js",
3658
+ global: "dayjs",
3659
+ crossorigin: "anonymous"
3660
+ },
3661
+ unpkg: {
3662
+ url: "https://unpkg.com/dayjs@1.11.13/dayjs.min.js",
3663
+ global: "dayjs",
3664
+ crossorigin: "anonymous"
3665
+ }
3666
+ },
3667
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3668
+ metadata: {
3669
+ description: "Fast 2kB alternative to Moment.js with the same modern API",
3670
+ homepage: "https://day.js.org",
3671
+ license: "MIT"
3672
+ }
3673
+ },
3674
+ "date-fns": {
3675
+ packageName: "date-fns",
3676
+ defaultVersion: "4.1.0",
3677
+ providers: {
3678
+ "esm.sh": {
3679
+ url: "https://esm.sh/date-fns@4.1.0",
3680
+ esm: true,
3681
+ crossorigin: "anonymous"
3682
+ },
3683
+ jsdelivr: {
3684
+ url: "https://cdn.jsdelivr.net/npm/date-fns@4.1.0/+esm",
3685
+ esm: true,
3686
+ crossorigin: "anonymous"
3687
+ }
3688
+ },
3689
+ preferredProviders: ["esm.sh", "jsdelivr"],
3690
+ metadata: {
3691
+ description: "Modern JavaScript date utility library",
3692
+ homepage: "https://date-fns.org",
3693
+ license: "MIT"
3694
+ }
3695
+ },
3696
+ // ============================================
3697
+ // Animation Libraries
3698
+ // ============================================
3699
+ "framer-motion": {
3700
+ packageName: "framer-motion",
3701
+ defaultVersion: "11.15.0",
3702
+ providers: {
3703
+ "esm.sh": {
3704
+ url: "https://esm.sh/framer-motion@11.15.0",
3705
+ esm: true,
3706
+ crossorigin: "anonymous",
3707
+ peerDependencies: ["react", "react-dom"]
3708
+ },
3709
+ jsdelivr: {
3710
+ url: "https://cdn.jsdelivr.net/npm/framer-motion@11.15.0/dist/framer-motion.js",
3711
+ global: "Motion",
3712
+ crossorigin: "anonymous",
3713
+ peerDependencies: ["react", "react-dom"]
3714
+ }
3715
+ },
3716
+ preferredProviders: ["esm.sh", "jsdelivr"],
3717
+ metadata: {
3718
+ description: "Production-ready motion library for React",
3719
+ homepage: "https://www.framer.com/motion/",
3720
+ license: "MIT"
3721
+ }
3722
+ },
3723
+ // ============================================
3724
+ // UI Component Libraries
3725
+ // ============================================
3726
+ "lucide-react": {
3727
+ packageName: "lucide-react",
3728
+ defaultVersion: "0.468.0",
3729
+ providers: {
3730
+ "esm.sh": {
3731
+ url: "https://esm.sh/lucide-react@0.468.0",
3732
+ esm: true,
3733
+ crossorigin: "anonymous",
3734
+ peerDependencies: ["react"]
3735
+ },
3736
+ jsdelivr: {
3737
+ url: "https://cdn.jsdelivr.net/npm/lucide-react@0.468.0/dist/esm/lucide-react.js",
3738
+ esm: true,
3739
+ crossorigin: "anonymous",
3740
+ peerDependencies: ["react"]
3741
+ }
3742
+ },
3743
+ preferredProviders: ["esm.sh", "jsdelivr"],
3744
+ metadata: {
3745
+ description: "Beautiful & consistent icon toolkit for React",
3746
+ homepage: "https://lucide.dev",
3747
+ license: "ISC"
3748
+ }
3749
+ },
3750
+ // ============================================
3751
+ // Markdown/Syntax Highlighting
3752
+ // ============================================
3753
+ marked: {
3754
+ packageName: "marked",
3755
+ defaultVersion: "15.0.4",
3756
+ providers: {
3757
+ cloudflare: {
3758
+ url: "https://cdnjs.cloudflare.com/ajax/libs/marked/15.0.4/marked.min.js",
3759
+ integrity: "sha512-Rn/d0sGeizGbk3VJEiYNDt/mMcfuzYoFkia3iBffv+HX8VUrHMo/0cKjZuxWGoZLPh/VxUcC9ais+RBFZW9EBg==",
3760
+ global: "marked",
3761
+ crossorigin: "anonymous"
3762
+ },
3763
+ jsdelivr: {
3764
+ url: "https://cdn.jsdelivr.net/npm/marked@15.0.4/marked.min.js",
3765
+ global: "marked",
3766
+ crossorigin: "anonymous"
3767
+ },
3768
+ unpkg: {
3769
+ url: "https://unpkg.com/marked@15.0.4/marked.min.js",
3770
+ global: "marked",
3771
+ crossorigin: "anonymous"
3772
+ }
3773
+ },
3774
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3775
+ metadata: {
3776
+ description: "A markdown parser and compiler",
3777
+ homepage: "https://marked.js.org",
3778
+ license: "MIT"
3779
+ }
3780
+ },
3781
+ "highlight.js": {
3782
+ packageName: "highlight.js",
3783
+ defaultVersion: "11.10.0",
3784
+ providers: {
3785
+ cloudflare: {
3786
+ url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js",
3787
+ integrity: "sha512-6yoqbrcLAHDWAdQmiRlHG4+m0g/CT/V9AGyxabG8j7Jk8j3v3k6mIP1iN/PvSofcWet2tf8SRn/j3L/+pb7LRQ==",
3788
+ global: "hljs",
3789
+ crossorigin: "anonymous"
3790
+ },
3791
+ jsdelivr: {
3792
+ url: "https://cdn.jsdelivr.net/npm/highlight.js@11.10.0/lib/core.min.js",
3793
+ global: "hljs",
3794
+ crossorigin: "anonymous"
3795
+ },
3796
+ unpkg: {
3797
+ url: "https://unpkg.com/highlight.js@11.10.0/lib/core.min.js",
3798
+ global: "hljs",
3799
+ crossorigin: "anonymous"
3800
+ }
3801
+ },
3802
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3803
+ metadata: {
3804
+ description: "Syntax highlighting for the web",
3805
+ homepage: "https://highlightjs.org",
3806
+ license: "BSD-3-Clause"
3807
+ }
3808
+ },
3809
+ // ============================================
3810
+ // Interactive Libraries
3811
+ // ============================================
3812
+ "htmx.org": {
3813
+ packageName: "htmx.org",
3814
+ defaultVersion: "2.0.4",
3815
+ providers: {
3816
+ cloudflare: {
3817
+ url: "https://cdnjs.cloudflare.com/ajax/libs/htmx/2.0.4/htmx.min.js",
3818
+ integrity: "sha512-2kIcAizYXhIn5IyXrMC72f2nh0JAtESHRpOieVw5dYPYeHwLCC2eKCqvdZDYRSEgasKrPpEPpRFjL8gqwBZWAA==",
3819
+ global: "htmx",
3820
+ crossorigin: "anonymous"
3821
+ },
3822
+ jsdelivr: {
3823
+ url: "https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js",
3824
+ global: "htmx",
3825
+ crossorigin: "anonymous"
3826
+ },
3827
+ unpkg: {
3828
+ url: "https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js",
3829
+ global: "htmx",
3830
+ crossorigin: "anonymous"
3831
+ }
3832
+ },
3833
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3834
+ metadata: {
3835
+ description: "High power tools for HTML",
3836
+ homepage: "https://htmx.org",
3837
+ license: "BSD-2-Clause"
3838
+ }
3839
+ },
3840
+ alpinejs: {
3841
+ packageName: "alpinejs",
3842
+ defaultVersion: "3.14.3",
3843
+ providers: {
3844
+ cloudflare: {
3845
+ url: "https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.14.3/cdn.min.js",
3846
+ integrity: "sha512-lrQ8FHgsWKFSuQFq8NKPJicjlvJFEIrCqEj8zeX7ZOUlHWltN/Iow4jND+x84jqTdDf9n+hvQpJjGDvOl/eDRA==",
3847
+ global: "Alpine",
3848
+ crossorigin: "anonymous"
3849
+ },
3850
+ jsdelivr: {
3851
+ url: "https://cdn.jsdelivr.net/npm/alpinejs@3.14.3/dist/cdn.min.js",
3852
+ global: "Alpine",
3853
+ crossorigin: "anonymous"
3854
+ },
3855
+ unpkg: {
3856
+ url: "https://unpkg.com/alpinejs@3.14.3/dist/cdn.min.js",
3857
+ global: "Alpine",
3858
+ crossorigin: "anonymous"
3859
+ }
3860
+ },
3861
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3862
+ metadata: {
3863
+ description: "A rugged, minimal framework for composing behavior directly in your markup",
3864
+ homepage: "https://alpinejs.dev",
3865
+ license: "MIT"
3866
+ }
3867
+ },
3868
+ // ============================================
3869
+ // Templating Libraries
3870
+ // ============================================
3871
+ handlebars: {
3872
+ packageName: "handlebars",
3873
+ defaultVersion: "4.7.8",
3874
+ providers: {
3875
+ cloudflare: {
3876
+ url: "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js",
3877
+ integrity: "sha512-E1dSFxg+wsfJ4HKjutk/WaCzK7S2wv1POn1RRPGh8ZK+ag9l244Vqxji3r6wgz9YBf6+vhQEYJZpSjqWFPg9gg==",
3878
+ global: "Handlebars",
3879
+ crossorigin: "anonymous"
3880
+ },
3881
+ jsdelivr: {
3882
+ url: "https://cdn.jsdelivr.net/npm/handlebars@4.7.8/dist/handlebars.min.js",
3883
+ global: "Handlebars",
3884
+ crossorigin: "anonymous"
3885
+ },
3886
+ unpkg: {
3887
+ url: "https://unpkg.com/handlebars@4.7.8/dist/handlebars.min.js",
3888
+ global: "Handlebars",
3889
+ crossorigin: "anonymous"
3890
+ }
3891
+ },
3892
+ preferredProviders: ["cloudflare", "jsdelivr", "unpkg"],
3893
+ metadata: {
3894
+ description: "Minimal templating on steroids",
3895
+ homepage: "https://handlebarsjs.com",
3896
+ license: "MIT"
3897
+ }
3898
+ }
3899
+ };
3900
+ var CDN_PROVIDER_PRIORITY = {
3901
+ claude: ["cloudflare"],
3902
+ // ONLY cloudflare for Claude
3903
+ openai: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3904
+ cursor: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3905
+ gemini: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3906
+ continue: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3907
+ cody: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"],
3908
+ unknown: ["cloudflare", "jsdelivr", "unpkg", "esm.sh"]
3909
+ // Default to cloudflare first
3910
+ };
3911
+ function lookupPackage(packageName, registry = DEFAULT_CDN_REGISTRY) {
3912
+ return registry[packageName];
3913
+ }
3914
+ function mergeRegistries(customRegistry) {
3915
+ return {
3916
+ ...DEFAULT_CDN_REGISTRY,
3917
+ ...customRegistry
3918
+ };
3919
+ }
3920
+ function getPackagePeerDependencies(packageName, registry = DEFAULT_CDN_REGISTRY) {
3921
+ const entry = lookupPackage(packageName, registry);
3922
+ if (!entry) return [];
3923
+ for (const provider of Object.keys(entry.providers)) {
3924
+ const config = entry.providers[provider];
3925
+ if (config?.peerDependencies) {
3926
+ return config.peerDependencies;
3927
+ }
3928
+ }
3929
+ return [];
3930
+ }
3931
+ function resolveAllDependencies(packageNames, platform = "unknown", registry = DEFAULT_CDN_REGISTRY) {
3932
+ const resolved = /* @__PURE__ */ new Set();
3933
+ const queue = [...packageNames];
3934
+ while (queue.length > 0) {
3935
+ const packageName = queue.shift();
3936
+ if (!packageName) continue;
3937
+ if (resolved.has(packageName)) continue;
3938
+ resolved.add(packageName);
3939
+ const peers = getPackagePeerDependencies(packageName, registry);
3940
+ for (const peer of peers) {
3941
+ if (!resolved.has(peer)) {
3942
+ queue.push(peer);
3943
+ }
3944
+ }
3945
+ }
3946
+ const result = [];
3947
+ const remaining = new Set(resolved);
3948
+ while (remaining.size > 0) {
3949
+ let added = false;
3950
+ for (const pkg of remaining) {
3951
+ const peers = getPackagePeerDependencies(pkg, registry);
3952
+ const allPeersResolved = peers.every((peer) => !remaining.has(peer) || result.includes(peer));
3953
+ if (allPeersResolved) {
3954
+ if (!result.includes(pkg)) {
3955
+ result.push(pkg);
3956
+ }
3957
+ remaining.delete(pkg);
3958
+ added = true;
3959
+ }
3960
+ }
3961
+ if (!added && remaining.size > 0) {
3962
+ const next = remaining.values().next().value;
3963
+ if (next !== void 0) {
3964
+ if (!result.includes(next)) {
3965
+ result.push(next);
3966
+ }
3967
+ remaining.delete(next);
3968
+ }
3969
+ }
3970
+ }
3971
+ return result;
3972
+ }
3973
+
3974
+ // libs/ui/src/dependency/import-parser.ts
3975
+ var IMPORT_PATTERNS = {
3976
+ /**
3977
+ * Named imports: import { foo, bar } from 'module'
3978
+ * Also handles renamed imports: import { foo as f } from 'module'
3979
+ */
3980
+ named: /import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
3981
+ /**
3982
+ * Default imports: import foo from 'module'
3983
+ */
3984
+ default: /import\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
3985
+ /**
3986
+ * Namespace imports: import * as foo from 'module'
3987
+ */
3988
+ namespace: /import\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
3989
+ /**
3990
+ * Side-effect imports: import 'module'
3991
+ */
3992
+ sideEffect: /import\s*['"]([^'"]+)['"]/g,
3993
+ /**
3994
+ * Dynamic imports: import('module') or await import('module')
3995
+ */
3996
+ dynamic: /(?:await\s+)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
3997
+ /**
3998
+ * Combined default and named: import foo, { bar } from 'module'
3999
+ */
4000
+ defaultAndNamed: /import\s+(\w+)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
4001
+ /**
4002
+ * Combined default and namespace: import foo, * as bar from 'module'
4003
+ */
4004
+ defaultAndNamespace: /import\s+(\w+)\s*,\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]/g,
4005
+ /**
4006
+ * Re-exports: export { foo } from 'module'
4007
+ */
4008
+ reExport: /export\s*\{[^}]+\}\s*from\s*['"]([^'"]+)['"]/g,
4009
+ /**
4010
+ * Re-export all: export * from 'module'
4011
+ */
4012
+ reExportAll: /export\s*\*\s*from\s*['"]([^'"]+)['"]/g
4013
+ };
4014
+ function parseNamedImports(namedString) {
4015
+ return namedString.split(",").map((s) => s.trim()).filter((s) => s.length > 0).map((s) => {
4016
+ const asMatch = s.match(/^(\w+)\s+as\s+\w+$/);
4017
+ return asMatch ? asMatch[1] : s;
4018
+ });
4019
+ }
4020
+ function isRelativeImport(specifier) {
4021
+ return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/");
4022
+ }
4023
+ function isExternalImport(specifier) {
4024
+ return !isRelativeImport(specifier) && !specifier.startsWith("#");
4025
+ }
4026
+ function getPackageName(specifier) {
4027
+ if (specifier.startsWith("@")) {
4028
+ const parts = specifier.split("/");
4029
+ if (parts.length >= 2) {
4030
+ return `${parts[0]}/${parts[1]}`;
4031
+ }
4032
+ return specifier;
4033
+ }
4034
+ const firstSlash = specifier.indexOf("/");
4035
+ return firstSlash === -1 ? specifier : specifier.slice(0, firstSlash);
4036
+ }
4037
+ function getLineNumber(source, index) {
4038
+ let line = 1;
4039
+ for (let i = 0; i < index && i < source.length; i++) {
4040
+ if (source[i] === "\n") {
4041
+ line++;
4042
+ }
4043
+ }
4044
+ return line;
4045
+ }
4046
+ function getColumnNumber(source, index) {
4047
+ let column = 0;
4048
+ for (let i = index - 1; i >= 0 && source[i] !== "\n"; i--) {
4049
+ column++;
4050
+ }
4051
+ return column;
4052
+ }
4053
+ function parseImports(source) {
4054
+ const imports = [];
4055
+ const seenStatements = /* @__PURE__ */ new Set();
4056
+ const addImport = (imp) => {
4057
+ const key = `${imp.type}:${imp.specifier}:${imp.statement}`;
4058
+ if (!seenStatements.has(key)) {
4059
+ seenStatements.add(key);
4060
+ imports.push(imp);
4061
+ }
4062
+ };
4063
+ let match;
4064
+ const defaultAndNamedRegex = new RegExp(IMPORT_PATTERNS.defaultAndNamed.source, "g");
4065
+ while ((match = defaultAndNamedRegex.exec(source)) !== null) {
4066
+ const [statement, defaultName, namedString, specifier] = match;
4067
+ const namedImports = parseNamedImports(namedString);
4068
+ addImport({
4069
+ statement,
4070
+ specifier,
4071
+ type: "default",
4072
+ defaultImport: defaultName,
4073
+ namedImports,
4074
+ line: getLineNumber(source, match.index),
4075
+ column: getColumnNumber(source, match.index)
4076
+ });
4077
+ }
4078
+ const defaultAndNamespaceRegex = new RegExp(IMPORT_PATTERNS.defaultAndNamespace.source, "g");
4079
+ while ((match = defaultAndNamespaceRegex.exec(source)) !== null) {
4080
+ const [statement, defaultName, namespaceName, specifier] = match;
4081
+ addImport({
4082
+ statement,
4083
+ specifier,
4084
+ type: "default",
4085
+ defaultImport: defaultName,
4086
+ namespaceImport: namespaceName,
4087
+ line: getLineNumber(source, match.index),
4088
+ column: getColumnNumber(source, match.index)
4089
+ });
4090
+ }
4091
+ const namedRegex = new RegExp(IMPORT_PATTERNS.named.source, "g");
4092
+ while ((match = namedRegex.exec(source)) !== null) {
4093
+ const [statement, namedString, specifier] = match;
4094
+ const namedImports = parseNamedImports(namedString);
4095
+ addImport({
4096
+ statement,
4097
+ specifier,
4098
+ type: "named",
4099
+ namedImports,
4100
+ line: getLineNumber(source, match.index),
4101
+ column: getColumnNumber(source, match.index)
4102
+ });
4103
+ }
4104
+ const defaultRegex = new RegExp(IMPORT_PATTERNS.default.source, "g");
4105
+ while ((match = defaultRegex.exec(source)) !== null) {
4106
+ const [statement, defaultName, specifier] = match;
4107
+ const afterMatch = source.slice(match.index + match[0].length - specifier.length - 2);
4108
+ if (afterMatch.startsWith(",")) continue;
4109
+ addImport({
4110
+ statement,
4111
+ specifier,
4112
+ type: "default",
4113
+ defaultImport: defaultName,
4114
+ line: getLineNumber(source, match.index),
4115
+ column: getColumnNumber(source, match.index)
4116
+ });
4117
+ }
4118
+ const namespaceRegex = new RegExp(IMPORT_PATTERNS.namespace.source, "g");
4119
+ while ((match = namespaceRegex.exec(source)) !== null) {
4120
+ const [statement, namespaceName, specifier] = match;
4121
+ addImport({
4122
+ statement,
4123
+ specifier,
4124
+ type: "namespace",
4125
+ namespaceImport: namespaceName,
4126
+ line: getLineNumber(source, match.index),
4127
+ column: getColumnNumber(source, match.index)
4128
+ });
4129
+ }
4130
+ const sideEffectRegex = new RegExp(IMPORT_PATTERNS.sideEffect.source, "g");
4131
+ while ((match = sideEffectRegex.exec(source)) !== null) {
4132
+ const [statement, specifier] = match;
4133
+ const beforeMatch = source.slice(Math.max(0, match.index - 50), match.index);
4134
+ if (beforeMatch.includes("from")) continue;
4135
+ addImport({
4136
+ statement,
4137
+ specifier,
4138
+ type: "side-effect",
4139
+ line: getLineNumber(source, match.index),
4140
+ column: getColumnNumber(source, match.index)
4141
+ });
4142
+ }
4143
+ const dynamicRegex = new RegExp(IMPORT_PATTERNS.dynamic.source, "g");
4144
+ while ((match = dynamicRegex.exec(source)) !== null) {
4145
+ const [statement, specifier] = match;
4146
+ addImport({
4147
+ statement,
4148
+ specifier,
4149
+ type: "dynamic",
4150
+ line: getLineNumber(source, match.index),
4151
+ column: getColumnNumber(source, match.index)
4152
+ });
4153
+ }
4154
+ const reExportRegex = new RegExp(IMPORT_PATTERNS.reExport.source, "g");
4155
+ while ((match = reExportRegex.exec(source)) !== null) {
4156
+ const [statement, specifier] = match;
4157
+ addImport({
4158
+ statement,
4159
+ specifier,
4160
+ type: "named",
4161
+ line: getLineNumber(source, match.index),
4162
+ column: getColumnNumber(source, match.index)
4163
+ });
4164
+ }
4165
+ const reExportAllRegex = new RegExp(IMPORT_PATTERNS.reExportAll.source, "g");
4166
+ while ((match = reExportAllRegex.exec(source)) !== null) {
4167
+ const [statement, specifier] = match;
4168
+ addImport({
4169
+ statement,
4170
+ specifier,
4171
+ type: "namespace",
4172
+ line: getLineNumber(source, match.index),
4173
+ column: getColumnNumber(source, match.index)
4174
+ });
4175
+ }
4176
+ const externalImports = imports.filter((imp) => isExternalImport(imp.specifier));
4177
+ const relativeImports = imports.filter((imp) => isRelativeImport(imp.specifier));
4178
+ const externalPackages = [...new Set(externalImports.map((imp) => getPackageName(imp.specifier)))];
4179
+ return {
4180
+ imports,
4181
+ externalImports,
4182
+ relativeImports,
4183
+ externalPackages
4184
+ };
4185
+ }
4186
+
4187
+ // libs/ui/src/dependency/import-map.ts
4188
+ function createImportMap(dependencies) {
4189
+ const imports = {};
4190
+ const integrity = {};
4191
+ for (const dep of dependencies) {
4192
+ imports[dep.packageName] = dep.cdnUrl;
4193
+ if (dep.integrity) {
4194
+ integrity[dep.cdnUrl] = dep.integrity;
4195
+ }
4196
+ }
4197
+ return {
4198
+ imports,
4199
+ integrity: Object.keys(integrity).length > 0 ? integrity : void 0
4200
+ };
4201
+ }
4202
+ function generateImportMapScriptTag(map) {
4203
+ const json = JSON.stringify(map, null, 2);
4204
+ return `<script type="importmap">
4205
+ ${json}
4206
+ </script>`;
4207
+ }
4208
+ function generateImportMapScriptTagMinified(map) {
4209
+ const json = JSON.stringify(map);
4210
+ return `<script type="importmap">${json}</script>`;
4211
+ }
4212
+ function generateUMDShim(dependencies, options = {}) {
4213
+ const { safe = true, minify = false } = options;
4214
+ const depsWithGlobals = dependencies.filter((d) => d.global && !d.esm);
4215
+ if (depsWithGlobals.length === 0) {
4216
+ return "";
4217
+ }
4218
+ const entries = depsWithGlobals.map((dep) => {
4219
+ const global = dep.global;
4220
+ return `'${dep.packageName}': { default: window.${global}, ...window.${global} }`;
4221
+ });
4222
+ const shimObject = `{
4223
+ ${entries.join(",\n ")}
4224
+ }`;
4225
+ const code = safe ? `(function() {
4226
+ try {
4227
+ window.__esm_shim = ${shimObject};
4228
+ } catch (e) {
4229
+ console.warn('UMD shim failed:', e);
4230
+ }
4231
+ })();` : `window.__esm_shim = ${shimObject};`;
4232
+ return minify ? code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1") : code;
4233
+ }
4234
+ function generateCDNScriptTags(dependencies) {
4235
+ return dependencies.filter((dep) => !dep.esm).map((dep) => {
4236
+ const attrs = [`src="${escapeHtmlAttr(dep.cdnUrl)}"`];
4237
+ if (dep.integrity) {
4238
+ attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
4239
+ }
4240
+ attrs.push('crossorigin="anonymous"');
4241
+ return `<script ${attrs.join(" ")}></script>`;
4242
+ });
4243
+ }
4244
+ function generateESMScriptTags(dependencies) {
4245
+ return dependencies.filter((dep) => dep.esm).map((dep) => {
4246
+ const attrs = ['type="module"', `src="${escapeHtmlAttr(dep.cdnUrl)}"`];
4247
+ if (dep.integrity) {
4248
+ attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
4249
+ }
4250
+ attrs.push('crossorigin="anonymous"');
4251
+ return `<script ${attrs.join(" ")}></script>`;
4252
+ });
4253
+ }
4254
+ function generateDependencyHTML(dependencies, options = {}) {
4255
+ const { minify = false, includeShim = true } = options;
4256
+ const parts = [];
4257
+ const importMap = createImportMap(dependencies);
4258
+ const importMapTag = minify ? generateImportMapScriptTagMinified(importMap) : generateImportMapScriptTag(importMap);
4259
+ parts.push(importMapTag);
4260
+ const umdTags = generateCDNScriptTags(dependencies);
4261
+ parts.push(...umdTags);
4262
+ if (includeShim) {
4263
+ const shim = generateUMDShim(dependencies, { minify });
4264
+ if (shim) {
4265
+ parts.push(`<script>${shim}</script>`);
4266
+ }
4267
+ }
4268
+ const esmTags = generateESMScriptTags(dependencies);
4269
+ parts.push(...esmTags);
4270
+ return parts.join(minify ? "" : "\n");
4271
+ }
4272
+
4273
+ // libs/ui/src/dependency/resolver.ts
4274
+ var DependencyResolutionError = class extends Error {
4275
+ constructor(packageName, reason) {
4276
+ super(`Failed to resolve dependency "${packageName}": ${reason}`);
4277
+ this.packageName = packageName;
4278
+ this.reason = reason;
4279
+ this.name = "DependencyResolutionError";
4280
+ }
4281
+ };
4282
+ var NoProviderError = class extends DependencyResolutionError {
4283
+ constructor(packageName, platform) {
4284
+ super(packageName, `No CDN provider available for platform "${platform}"`);
4285
+ this.platform = platform;
4286
+ this.name = "NoProviderError";
4287
+ }
4288
+ };
4289
+ var DependencyResolver = class {
4290
+ options;
4291
+ registry;
4292
+ constructor(options = {}) {
4293
+ this.options = {
4294
+ platform: options.platform ?? "unknown",
4295
+ preferredProviders: options.preferredProviders ?? CDN_PROVIDER_PRIORITY[options.platform ?? "unknown"],
4296
+ customRegistry: options.customRegistry ?? {},
4297
+ strictMode: options.strictMode ?? true,
4298
+ requireIntegrity: options.requireIntegrity ?? false
4299
+ };
4300
+ this.registry = mergeRegistries(this.options.customRegistry);
4301
+ }
4302
+ /**
4303
+ * Resolve a single package to its CDN dependency.
4304
+ *
4305
+ * @param packageName - NPM package name
4306
+ * @param override - Optional explicit CDN dependency override
4307
+ * @returns Resolved dependency, or null in non-strict mode if package is not found (should be bundled)
4308
+ * @throws DependencyResolutionError if package cannot be resolved in strict mode
4309
+ */
4310
+ resolve(packageName, override) {
4311
+ if (override) {
4312
+ return this.createResolvedDependency(packageName, override, "custom");
4313
+ }
4314
+ const entry = lookupPackage(packageName, this.registry);
4315
+ if (!entry) {
4316
+ if (this.options.strictMode) {
4317
+ throw new DependencyResolutionError(
4318
+ packageName,
4319
+ 'Package not found in CDN registry. Add it to "dependencies" for explicit CDN configuration.'
4320
+ );
4321
+ }
4322
+ return null;
4323
+ }
4324
+ const providerPriority = this.options.preferredProviders;
4325
+ for (const provider of providerPriority) {
4326
+ const config = entry.providers[provider];
4327
+ if (config?.url) {
4328
+ if (this.options.requireIntegrity && !config.integrity) {
4329
+ continue;
4330
+ }
4331
+ return this.createResolvedDependency(packageName, config, provider, entry.defaultVersion);
4332
+ }
4333
+ }
4334
+ throw new NoProviderError(packageName, this.options.platform);
4335
+ }
4336
+ /**
4337
+ * Resolve multiple packages.
4338
+ *
4339
+ * @param packageNames - Array of package names
4340
+ * @param overrides - Optional explicit overrides for specific packages
4341
+ * @returns Array of resolved dependencies (in dependency order)
4342
+ */
4343
+ resolveMany(packageNames, overrides) {
4344
+ const allPackages = resolveAllDependencies(packageNames, this.options.platform, this.registry);
4345
+ const resolved = [];
4346
+ for (const pkgName of allPackages) {
4347
+ try {
4348
+ const override = overrides?.[pkgName];
4349
+ const dep = this.resolve(pkgName, override);
4350
+ if (dep) {
4351
+ resolved.push(dep);
4352
+ }
4353
+ } catch (error) {
4354
+ if (this.options.strictMode) {
4355
+ throw error;
4356
+ }
4357
+ }
4358
+ }
4359
+ return resolved;
4360
+ }
4361
+ /**
4362
+ * Resolve dependencies from source code.
4363
+ *
4364
+ * Parses the source to extract imports, then resolves external packages
4365
+ * that are in the externals list.
4366
+ *
4367
+ * @param source - Source code to parse
4368
+ * @param externals - Package names to resolve from CDN (others are bundled)
4369
+ * @param overrides - Optional explicit CDN overrides
4370
+ * @returns Resolved dependencies
4371
+ */
4372
+ resolveFromSource(source, externals, overrides) {
4373
+ const parseResult = parseImports(source);
4374
+ const packagesToResolve = parseResult.externalPackages.filter((pkg) => externals.includes(pkg));
4375
+ return this.resolveMany(packagesToResolve, overrides);
4376
+ }
4377
+ /**
4378
+ * Generate an import map for resolved dependencies.
4379
+ *
4380
+ * @param dependencies - Resolved dependencies
4381
+ * @returns Browser import map
4382
+ */
4383
+ generateImportMap(dependencies) {
4384
+ return createImportMap(dependencies);
4385
+ }
4386
+ /**
4387
+ * Check if a package can be resolved for the current platform.
4388
+ *
4389
+ * @param packageName - Package name to check
4390
+ * @returns true if the package can be resolved
4391
+ */
4392
+ canResolve(packageName) {
4393
+ try {
4394
+ const result = this.resolve(packageName);
4395
+ return result !== null;
4396
+ } catch {
4397
+ return false;
4398
+ }
4399
+ }
4400
+ /**
4401
+ * Get the resolved CDN URL for a package.
4402
+ *
4403
+ * @param packageName - Package name
4404
+ * @param override - Optional explicit override
4405
+ * @returns CDN URL or undefined if cannot resolve
4406
+ */
4407
+ getUrl(packageName, override) {
4408
+ try {
4409
+ const resolved = this.resolve(packageName, override);
4410
+ return resolved?.cdnUrl;
4411
+ } catch {
4412
+ return void 0;
4413
+ }
4414
+ }
4415
+ /**
4416
+ * Get peer dependencies for a package.
4417
+ */
4418
+ getPeerDependencies(packageName) {
4419
+ return getPackagePeerDependencies(packageName, this.registry);
4420
+ }
4421
+ /**
4422
+ * Create the current registry (default + custom).
4423
+ */
4424
+ getRegistry() {
4425
+ return this.registry;
4426
+ }
4427
+ /**
4428
+ * Get the current platform.
4429
+ */
4430
+ getPlatform() {
4431
+ return this.options.platform;
4432
+ }
4433
+ /**
4434
+ * Create a resolved dependency object.
4435
+ */
4436
+ createResolvedDependency(packageName, config, provider, version) {
4437
+ return {
4438
+ packageName,
4439
+ version: version ?? this.extractVersionFromUrl(config.url) ?? "latest",
4440
+ cdnUrl: config.url,
4441
+ integrity: config.integrity,
4442
+ global: config.global,
4443
+ esm: config.esm ?? false,
4444
+ provider
4445
+ };
4446
+ }
4447
+ /**
4448
+ * Try to extract version from CDN URL.
4449
+ */
4450
+ extractVersionFromUrl(url) {
4451
+ const versionMatch = url.match(/@(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
4452
+ if (versionMatch) {
4453
+ return versionMatch[1];
4454
+ }
4455
+ const versionMatch2 = url.match(/\/v?(\d+\.\d+\.\d+)\//);
4456
+ if (versionMatch2) {
4457
+ return versionMatch2[1];
4458
+ }
4459
+ return void 0;
4460
+ }
4461
+ };
4462
+
4463
+ // libs/ui/src/bundler/file-cache/component-builder.ts
4464
+ var ComponentBuilder = class {
4465
+ storage;
4466
+ esbuild = null;
4467
+ constructor(storage) {
4468
+ this.storage = storage;
4469
+ }
4470
+ /**
4471
+ * Build a component from a file path.
4472
+ */
4473
+ async build(options) {
4474
+ const startTime = performance.now();
4475
+ const {
4476
+ entryPath,
4477
+ toolName,
4478
+ externals = [],
4479
+ dependencies = {},
4480
+ bundleOptions = {},
4481
+ platform = "unknown",
4482
+ skipCache = false,
4483
+ ssr = false,
4484
+ ssrContext = {},
4485
+ executeCode: executeCode3
4486
+ } = options;
4487
+ const absoluteEntryPath = (0, import_path3.resolve)(entryPath);
4488
+ if (!(0, import_fs3.existsSync)(absoluteEntryPath)) {
4489
+ throw new Error(`Entry file not found: ${absoluteEntryPath}`);
4490
+ }
4491
+ const hashResult = await calculateComponentHash({
4492
+ entryPath: absoluteEntryPath,
4493
+ externals,
4494
+ dependencies,
4495
+ bundleOptions
4496
+ });
4497
+ if (!skipCache) {
4498
+ const cached = await this.storage.get(hashResult.hash);
4499
+ if (cached) {
4500
+ return {
4501
+ manifest: cached,
4502
+ cached: true,
4503
+ buildTimeMs: performance.now() - startTime
4504
+ };
4505
+ }
4506
+ }
4507
+ const source = await (0, import_promises3.readFile)(absoluteEntryPath, "utf8");
4508
+ const resolver = new DependencyResolver({ platform });
4509
+ const resolvedDeps = [];
4510
+ for (const pkg of externals) {
4511
+ try {
4512
+ const override = dependencies[pkg];
4513
+ const resolved = resolver.resolve(pkg, override);
4514
+ if (resolved) {
4515
+ resolvedDeps.push(resolved);
4516
+ }
4517
+ } catch (error) {
4518
+ console.warn(`Failed to resolve external "${pkg}": ${error}`);
4519
+ }
4520
+ }
4521
+ const allExternals = new Set(externals);
4522
+ for (const dep of resolvedDeps) {
4523
+ const entry = resolver.getRegistry()[dep.packageName];
4524
+ if (entry?.providers) {
4525
+ const providerConfig = Object.values(entry.providers)[0];
4526
+ if (providerConfig?.peerDependencies) {
4527
+ for (const peer of providerConfig.peerDependencies) {
4528
+ if (!allExternals.has(peer)) {
4529
+ allExternals.add(peer);
4530
+ try {
4531
+ const peerOverride = dependencies[peer];
4532
+ const resolved = resolver.resolve(peer, peerOverride);
4533
+ if (resolved) {
4534
+ resolvedDeps.push(resolved);
4535
+ }
4536
+ } catch {
4537
+ }
4538
+ }
4539
+ }
4540
+ }
4541
+ }
4542
+ }
4543
+ const importMap = createImportMap(resolvedDeps);
4544
+ const bundleResult = await this.bundleComponent({
4545
+ source,
4546
+ entryPath: absoluteEntryPath,
4547
+ externals: Array.from(allExternals),
4548
+ bundleOptions
4549
+ });
4550
+ let ssrHtml;
4551
+ if (ssr) {
4552
+ ssrHtml = await this.renderSSR(bundleResult.code, ssrContext, resolvedDeps, executeCode3);
4553
+ }
4554
+ const manifest = {
4555
+ version: "1.0",
4556
+ buildId: (0, import_crypto3.randomUUID)(),
4557
+ toolName,
4558
+ entryPath: absoluteEntryPath,
4559
+ contentHash: hashResult.hash,
4560
+ dependencies: resolvedDeps,
4561
+ outputs: {
4562
+ code: bundleResult.code,
4563
+ sourceMap: bundleResult.map,
4564
+ ssrHtml
4565
+ },
4566
+ importMap,
4567
+ metadata: {
4568
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4569
+ buildTimeMs: performance.now() - startTime,
4570
+ totalSize: Buffer.byteLength(bundleResult.code, "utf8"),
4571
+ bundlerVersion: bundleResult.bundlerVersion
4572
+ }
4573
+ };
4574
+ await this.storage.set(hashResult.hash, manifest);
4575
+ return {
4576
+ manifest,
4577
+ cached: false,
4578
+ buildTimeMs: performance.now() - startTime
4579
+ };
4580
+ }
4581
+ /**
4582
+ * Build multiple components.
4583
+ */
4584
+ async buildMany(options) {
4585
+ return Promise.all(options.map((opt) => this.build(opt)));
4586
+ }
4587
+ /**
4588
+ * Check if a component needs rebuilding.
4589
+ */
4590
+ async needsRebuild(options) {
4591
+ const absoluteEntryPath = (0, import_path3.resolve)(options.entryPath);
4592
+ const hashResult = await calculateComponentHash({
4593
+ entryPath: absoluteEntryPath,
4594
+ externals: options.externals,
4595
+ dependencies: options.dependencies,
4596
+ bundleOptions: options.bundleOptions
4597
+ });
4598
+ const cached = await this.storage.has(hashResult.hash);
4599
+ return !cached;
4600
+ }
4601
+ /**
4602
+ * Get a cached build if it exists.
4603
+ */
4604
+ async getCached(options) {
4605
+ const absoluteEntryPath = (0, import_path3.resolve)(options.entryPath);
4606
+ const hashResult = await calculateComponentHash({
4607
+ entryPath: absoluteEntryPath,
4608
+ externals: options.externals,
4609
+ dependencies: options.dependencies,
4610
+ bundleOptions: options.bundleOptions
4611
+ });
4612
+ return this.storage.get(hashResult.hash);
4613
+ }
4614
+ /**
4615
+ * Invalidate a cached build.
4616
+ */
4617
+ async invalidate(contentHash) {
4618
+ return this.storage.delete(contentHash);
4619
+ }
4620
+ /**
4621
+ * Generate complete HTML for a built component.
4622
+ */
4623
+ generateHTML(manifest, minify = false) {
4624
+ const parts = [];
4625
+ const dependencyHtml = generateDependencyHTML(manifest.dependencies, { minify });
4626
+ parts.push(dependencyHtml);
4627
+ parts.push(`<script type="module">${manifest.outputs.code}</script>`);
4628
+ return parts.join(minify ? "" : "\n");
4629
+ }
4630
+ /**
4631
+ * Bundle a component using esbuild.
4632
+ */
4633
+ async bundleComponent(options) {
4634
+ const { source, entryPath, externals, bundleOptions } = options;
4635
+ if (!this.esbuild) {
4636
+ try {
4637
+ this.esbuild = await import("esbuild");
4638
+ } catch {
4639
+ throw new Error("esbuild is required for component building. Install with: npm install esbuild");
4640
+ }
4641
+ }
4642
+ const ext = (0, import_path3.extname)(entryPath).toLowerCase();
4643
+ const loader = ext === ".tsx" ? "tsx" : ext === ".ts" ? "ts" : ext === ".jsx" ? "jsx" : "js";
4644
+ try {
4645
+ const result = await this.esbuild.transform(source, {
4646
+ loader,
4647
+ format: "esm",
4648
+ minify: bundleOptions.minify ?? process.env["NODE_ENV"] === "production",
4649
+ sourcemap: bundleOptions.sourceMaps ? "inline" : false,
4650
+ target: bundleOptions.target ?? "es2020",
4651
+ treeShaking: bundleOptions.treeShake ?? true,
4652
+ jsx: "automatic",
4653
+ jsxImportSource: bundleOptions.jsxImportSource ?? "react",
4654
+ // Mark externals for later import map resolution
4655
+ banner: externals.length > 0 ? `/* externals: ${externals.join(", ")} */` : void 0
4656
+ });
4657
+ return {
4658
+ code: result.code,
4659
+ map: result.map || void 0,
4660
+ bundlerVersion: this.esbuild.version
4661
+ };
4662
+ } catch (error) {
4663
+ throw new Error(`Bundle failed for ${entryPath}: ${error}`);
4664
+ }
4665
+ }
4666
+ /**
4667
+ * Perform server-side rendering.
4668
+ */
4669
+ async renderSSR(code, context, dependencies, executeCode3) {
4670
+ const hasReact = dependencies.some((d) => d.packageName === "react");
4671
+ if (!hasReact) {
4672
+ console.warn("SSR requires React as an external dependency");
4673
+ return void 0;
4674
+ }
4675
+ try {
4676
+ const React = await import("react");
4677
+ const ReactDOMServer = await import("react-dom/server");
4678
+ const exports2 = {};
4679
+ const module2 = { exports: exports2 };
4680
+ if (executeCode3) {
4681
+ executeCode3(code, exports2, module2, React);
4682
+ } else {
4683
+ const fn = new Function("exports", "module", "React", code);
4684
+ fn(exports2, module2, React);
4685
+ }
4686
+ const Component = module2.exports.default || module2.exports;
4687
+ if (typeof Component !== "function") {
4688
+ console.warn("SSR: No default component export found");
4689
+ return void 0;
4690
+ }
4691
+ const element = React.createElement(Component, context);
4692
+ return ReactDOMServer.renderToString(element);
4693
+ } catch (error) {
4694
+ console.warn(`SSR failed: ${error}`);
4695
+ return void 0;
4696
+ }
4697
+ }
4698
+ };
4699
+ async function createFilesystemBuilder(cacheDir = ".frontmcp-cache/builds") {
4700
+ const { FilesystemStorage: FilesystemStorage2 } = await Promise.resolve().then(() => (init_filesystem(), filesystem_exports));
4701
+ const storage = new FilesystemStorage2({ cacheDir });
4702
+ await storage.initialize();
4703
+ return new ComponentBuilder(storage);
4704
+ }
4705
+ async function createRedisBuilder(redisClient, keyPrefix = "frontmcp:ui:build:") {
4706
+ const { RedisStorage: RedisStorage2 } = await Promise.resolve().then(() => (init_redis(), redis_exports));
4707
+ const storage = new RedisStorage2({
4708
+ client: redisClient,
4709
+ keyPrefix
4710
+ });
4711
+ await storage.initialize();
4712
+ return new ComponentBuilder(storage);
4713
+ }
4714
+ // Annotate the CommonJS export names for ESM import in node:
4715
+ 0 && (module.exports = {
4716
+ BundlerCache,
4717
+ ComponentBuilder,
4718
+ DEFAULT_BUNDLER_OPTIONS,
4719
+ DEFAULT_BUNDLE_OPTIONS,
4720
+ DEFAULT_SECURITY_POLICY,
4721
+ DEFAULT_STATIC_HTML_OPTIONS,
4722
+ DEFAULT_STORAGE_OPTIONS,
4723
+ ExecutionError,
4724
+ FilesystemStorage,
4725
+ InMemoryBundler,
4726
+ RedisStorage,
4727
+ STATIC_HTML_CDN,
4728
+ SecurityError,
4729
+ buildIdFromHash,
4730
+ calculateComponentHash,
4731
+ calculateManifestSize,
4732
+ calculateQuickHash,
4733
+ createBundler,
4734
+ createCacheKey,
4735
+ createFilesystemBuilder,
4736
+ createFilesystemStorage,
4737
+ createRedisBuilder,
4738
+ createRedisStorage,
4739
+ executeCode,
4740
+ executeDefault,
4741
+ generateBuildId,
4742
+ getCdnTypeForPlatform,
4743
+ hashContent,
4744
+ hashFile,
4745
+ hashFiles,
4746
+ isExecutionError,
4747
+ mergePolicy,
4748
+ sha256,
4749
+ sha256Buffer,
4750
+ throwOnViolations,
4751
+ validateImports,
4752
+ validateSize,
4753
+ validateSource
4754
+ });