@frontmcp/ui 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (805) hide show
  1. package/README.md +140 -362
  2. package/bridge/adapters/base-adapter.d.ts +104 -0
  3. package/bridge/adapters/base-adapter.d.ts.map +1 -0
  4. package/bridge/adapters/claude.adapter.d.ts +67 -0
  5. package/bridge/adapters/claude.adapter.d.ts.map +1 -0
  6. package/bridge/adapters/ext-apps.adapter.d.ts +143 -0
  7. package/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
  8. package/bridge/adapters/gemini.adapter.d.ts +64 -0
  9. package/bridge/adapters/gemini.adapter.d.ts.map +1 -0
  10. package/bridge/adapters/generic.adapter.d.ts +56 -0
  11. package/bridge/adapters/generic.adapter.d.ts.map +1 -0
  12. package/bridge/adapters/index.d.ts +26 -0
  13. package/bridge/adapters/index.d.ts.map +1 -0
  14. package/bridge/adapters/openai.adapter.d.ts +65 -0
  15. package/bridge/adapters/openai.adapter.d.ts.map +1 -0
  16. package/bridge/core/adapter-registry.d.ts +122 -0
  17. package/bridge/core/adapter-registry.d.ts.map +1 -0
  18. package/bridge/core/bridge-factory.d.ts +199 -0
  19. package/bridge/core/bridge-factory.d.ts.map +1 -0
  20. package/bridge/core/index.d.ts +10 -0
  21. package/bridge/core/index.d.ts.map +1 -0
  22. package/bridge/index.d.ts +62 -0
  23. package/bridge/index.d.ts.map +1 -0
  24. package/bridge/index.js +2540 -0
  25. package/bridge/runtime/iife-generator.d.ts +62 -0
  26. package/bridge/runtime/iife-generator.d.ts.map +1 -0
  27. package/bridge/runtime/index.d.ts +10 -0
  28. package/bridge/runtime/index.d.ts.map +1 -0
  29. package/bridge/types.d.ts +386 -0
  30. package/bridge/types.d.ts.map +1 -0
  31. package/bundler/bundler.d.ts +208 -0
  32. package/bundler/bundler.d.ts.map +1 -0
  33. package/bundler/cache.d.ts +173 -0
  34. package/bundler/cache.d.ts.map +1 -0
  35. package/bundler/file-cache/component-builder.d.ts +167 -0
  36. package/bundler/file-cache/component-builder.d.ts.map +1 -0
  37. package/bundler/file-cache/hash-calculator.d.ts +155 -0
  38. package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  39. package/bundler/file-cache/index.d.ts +12 -0
  40. package/bundler/file-cache/index.d.ts.map +1 -0
  41. package/bundler/file-cache/storage/filesystem.d.ts +149 -0
  42. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  43. package/bundler/file-cache/storage/index.d.ts +11 -0
  44. package/bundler/file-cache/storage/index.d.ts.map +1 -0
  45. package/bundler/file-cache/storage/interface.d.ts +152 -0
  46. package/bundler/file-cache/storage/interface.d.ts.map +1 -0
  47. package/bundler/file-cache/storage/redis.d.ts +139 -0
  48. package/bundler/file-cache/storage/redis.d.ts.map +1 -0
  49. package/bundler/index.d.ts +43 -0
  50. package/bundler/index.d.ts.map +1 -0
  51. package/bundler/index.js +3707 -0
  52. package/bundler/sandbox/enclave-adapter.d.ts +121 -0
  53. package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  54. package/bundler/sandbox/executor.d.ts +14 -0
  55. package/bundler/sandbox/executor.d.ts.map +1 -0
  56. package/bundler/sandbox/policy.d.ts +62 -0
  57. package/bundler/sandbox/policy.d.ts.map +1 -0
  58. package/bundler/types.d.ts +702 -0
  59. package/bundler/types.d.ts.map +1 -0
  60. package/components/alert.d.ts +66 -0
  61. package/components/alert.d.ts.map +1 -0
  62. package/components/alert.schema.d.ts +98 -0
  63. package/components/alert.schema.d.ts.map +1 -0
  64. package/components/avatar.d.ts +77 -0
  65. package/components/avatar.d.ts.map +1 -0
  66. package/components/avatar.schema.d.ts +170 -0
  67. package/components/avatar.schema.d.ts.map +1 -0
  68. package/components/badge.d.ts +64 -0
  69. package/components/badge.d.ts.map +1 -0
  70. package/components/badge.schema.d.ts +91 -0
  71. package/components/badge.schema.d.ts.map +1 -0
  72. package/components/button.d.ts +100 -0
  73. package/components/button.d.ts.map +1 -0
  74. package/components/button.schema.d.ts +120 -0
  75. package/components/button.schema.d.ts.map +1 -0
  76. package/components/card.d.ts +53 -0
  77. package/components/card.d.ts.map +1 -0
  78. package/components/card.schema.d.ts +93 -0
  79. package/components/card.schema.d.ts.map +1 -0
  80. package/components/form.d.ts +212 -0
  81. package/components/form.d.ts.map +1 -0
  82. package/components/form.schema.d.ts +365 -0
  83. package/components/form.schema.d.ts.map +1 -0
  84. package/components/index.d.ts +29 -0
  85. package/components/index.d.ts.map +1 -0
  86. package/components/index.js +2525 -0
  87. package/components/list.d.ts +121 -0
  88. package/components/list.d.ts.map +1 -0
  89. package/components/list.schema.d.ts +129 -0
  90. package/components/list.schema.d.ts.map +1 -0
  91. package/components/modal.d.ts +100 -0
  92. package/components/modal.d.ts.map +1 -0
  93. package/components/modal.schema.d.ts +151 -0
  94. package/components/modal.schema.d.ts.map +1 -0
  95. package/components/table.d.ts +91 -0
  96. package/components/table.d.ts.map +1 -0
  97. package/components/table.schema.d.ts +123 -0
  98. package/components/table.schema.d.ts.map +1 -0
  99. package/esm/bridge/adapters/base-adapter.d.ts +104 -0
  100. package/esm/bridge/adapters/base-adapter.d.ts.map +1 -0
  101. package/esm/bridge/adapters/claude.adapter.d.ts +67 -0
  102. package/esm/bridge/adapters/claude.adapter.d.ts.map +1 -0
  103. package/esm/bridge/adapters/ext-apps.adapter.d.ts +143 -0
  104. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +1 -0
  105. package/esm/bridge/adapters/gemini.adapter.d.ts +64 -0
  106. package/esm/bridge/adapters/gemini.adapter.d.ts.map +1 -0
  107. package/esm/bridge/adapters/generic.adapter.d.ts +56 -0
  108. package/esm/bridge/adapters/generic.adapter.d.ts.map +1 -0
  109. package/esm/bridge/adapters/index.d.ts +26 -0
  110. package/esm/bridge/adapters/index.d.ts.map +1 -0
  111. package/esm/bridge/adapters/openai.adapter.d.ts +65 -0
  112. package/esm/bridge/adapters/openai.adapter.d.ts.map +1 -0
  113. package/esm/bridge/core/adapter-registry.d.ts +122 -0
  114. package/esm/bridge/core/adapter-registry.d.ts.map +1 -0
  115. package/esm/bridge/core/bridge-factory.d.ts +199 -0
  116. package/esm/bridge/core/bridge-factory.d.ts.map +1 -0
  117. package/esm/bridge/core/index.d.ts +10 -0
  118. package/esm/bridge/core/index.d.ts.map +1 -0
  119. package/esm/bridge/index.d.ts +62 -0
  120. package/esm/bridge/index.d.ts.map +1 -0
  121. package/esm/bridge/index.js +2487 -0
  122. package/esm/bridge/runtime/iife-generator.d.ts +62 -0
  123. package/esm/bridge/runtime/iife-generator.d.ts.map +1 -0
  124. package/esm/bridge/runtime/index.d.ts +10 -0
  125. package/esm/bridge/runtime/index.d.ts.map +1 -0
  126. package/esm/bridge/types.d.ts +386 -0
  127. package/esm/bridge/types.d.ts.map +1 -0
  128. package/esm/bundler/bundler.d.ts +208 -0
  129. package/esm/bundler/bundler.d.ts.map +1 -0
  130. package/esm/bundler/cache.d.ts +173 -0
  131. package/esm/bundler/cache.d.ts.map +1 -0
  132. package/esm/bundler/file-cache/component-builder.d.ts +167 -0
  133. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
  134. package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
  135. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  136. package/esm/bundler/file-cache/index.d.ts +12 -0
  137. package/esm/bundler/file-cache/index.d.ts.map +1 -0
  138. package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
  139. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  140. package/esm/bundler/file-cache/storage/index.d.ts +11 -0
  141. package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
  142. package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
  143. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
  144. package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
  145. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
  146. package/esm/bundler/index.d.ts +43 -0
  147. package/esm/bundler/index.d.ts.map +1 -0
  148. package/esm/bundler/index.js +3640 -0
  149. package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
  150. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  151. package/esm/bundler/sandbox/executor.d.ts +14 -0
  152. package/esm/bundler/sandbox/executor.d.ts.map +1 -0
  153. package/esm/bundler/sandbox/policy.d.ts +62 -0
  154. package/esm/bundler/sandbox/policy.d.ts.map +1 -0
  155. package/esm/bundler/types.d.ts +702 -0
  156. package/esm/bundler/types.d.ts.map +1 -0
  157. package/esm/components/alert.d.ts +66 -0
  158. package/esm/components/alert.d.ts.map +1 -0
  159. package/esm/components/alert.schema.d.ts +98 -0
  160. package/esm/components/alert.schema.d.ts.map +1 -0
  161. package/esm/components/avatar.d.ts +77 -0
  162. package/esm/components/avatar.d.ts.map +1 -0
  163. package/esm/components/avatar.schema.d.ts +170 -0
  164. package/esm/components/avatar.schema.d.ts.map +1 -0
  165. package/esm/components/badge.d.ts +64 -0
  166. package/esm/components/badge.d.ts.map +1 -0
  167. package/esm/components/badge.schema.d.ts +91 -0
  168. package/esm/components/badge.schema.d.ts.map +1 -0
  169. package/esm/components/button.d.ts +100 -0
  170. package/esm/components/button.d.ts.map +1 -0
  171. package/esm/components/button.schema.d.ts +120 -0
  172. package/esm/components/button.schema.d.ts.map +1 -0
  173. package/esm/components/card.d.ts +53 -0
  174. package/esm/components/card.d.ts.map +1 -0
  175. package/esm/components/card.schema.d.ts +93 -0
  176. package/esm/components/card.schema.d.ts.map +1 -0
  177. package/esm/components/form.d.ts +212 -0
  178. package/esm/components/form.d.ts.map +1 -0
  179. package/esm/components/form.schema.d.ts +365 -0
  180. package/esm/components/form.schema.d.ts.map +1 -0
  181. package/esm/components/index.d.ts +29 -0
  182. package/esm/components/index.d.ts.map +1 -0
  183. package/esm/components/index.js +2396 -0
  184. package/esm/components/list.d.ts +121 -0
  185. package/esm/components/list.d.ts.map +1 -0
  186. package/esm/components/list.schema.d.ts +129 -0
  187. package/esm/components/list.schema.d.ts.map +1 -0
  188. package/esm/components/modal.d.ts +100 -0
  189. package/esm/components/modal.d.ts.map +1 -0
  190. package/esm/components/modal.schema.d.ts +151 -0
  191. package/esm/components/modal.schema.d.ts.map +1 -0
  192. package/esm/components/table.d.ts +91 -0
  193. package/esm/components/table.d.ts.map +1 -0
  194. package/esm/components/table.schema.d.ts +123 -0
  195. package/esm/components/table.schema.d.ts.map +1 -0
  196. package/esm/index.d.ts +40 -0
  197. package/esm/index.d.ts.map +1 -0
  198. package/esm/index.js +8326 -0
  199. package/esm/layouts/base.d.ts +86 -0
  200. package/esm/layouts/base.d.ts.map +1 -0
  201. package/esm/layouts/index.d.ts +8 -0
  202. package/esm/layouts/index.d.ts.map +1 -0
  203. package/esm/layouts/index.js +409 -0
  204. package/esm/layouts/presets.d.ts +134 -0
  205. package/esm/layouts/presets.d.ts.map +1 -0
  206. package/esm/package.json +72 -0
  207. package/esm/pages/consent.d.ts +117 -0
  208. package/esm/pages/consent.d.ts.map +1 -0
  209. package/esm/pages/error.d.ts +101 -0
  210. package/esm/pages/error.d.ts.map +1 -0
  211. package/esm/pages/index.d.ts +9 -0
  212. package/esm/pages/index.d.ts.map +1 -0
  213. package/esm/pages/index.js +1036 -0
  214. package/esm/react/Alert.d.ts +101 -0
  215. package/esm/react/Alert.d.ts.map +1 -0
  216. package/esm/react/Badge.d.ts +100 -0
  217. package/esm/react/Badge.d.ts.map +1 -0
  218. package/esm/react/Button.d.ts +108 -0
  219. package/esm/react/Button.d.ts.map +1 -0
  220. package/esm/react/Card.d.ts +103 -0
  221. package/esm/react/Card.d.ts.map +1 -0
  222. package/esm/react/hooks/context.d.ts +179 -0
  223. package/esm/react/hooks/context.d.ts.map +1 -0
  224. package/esm/react/hooks/index.d.ts +42 -0
  225. package/esm/react/hooks/index.d.ts.map +1 -0
  226. package/esm/react/hooks/tools.d.ts +284 -0
  227. package/esm/react/hooks/tools.d.ts.map +1 -0
  228. package/esm/react/index.d.ts +80 -0
  229. package/esm/react/index.d.ts.map +1 -0
  230. package/esm/react/index.js +3124 -0
  231. package/esm/react/types.d.ts +105 -0
  232. package/esm/react/types.d.ts.map +1 -0
  233. package/esm/react/utils.d.ts +43 -0
  234. package/esm/react/utils.d.ts.map +1 -0
  235. package/esm/render/index.d.ts +8 -0
  236. package/esm/render/index.d.ts.map +1 -0
  237. package/esm/render/index.js +45 -0
  238. package/esm/render/prerender.d.ts +57 -0
  239. package/esm/render/prerender.d.ts.map +1 -0
  240. package/esm/renderers/index.d.ts +21 -0
  241. package/esm/renderers/index.d.ts.map +1 -0
  242. package/esm/renderers/index.js +381 -0
  243. package/esm/renderers/react.adapter.d.ts +70 -0
  244. package/esm/renderers/react.adapter.d.ts.map +1 -0
  245. package/esm/renderers/react.renderer.d.ts +96 -0
  246. package/esm/renderers/react.renderer.d.ts.map +1 -0
  247. package/esm/universal/UniversalApp.d.ts +108 -0
  248. package/esm/universal/UniversalApp.d.ts.map +1 -0
  249. package/esm/universal/cached-runtime.d.ts +115 -0
  250. package/esm/universal/cached-runtime.d.ts.map +1 -0
  251. package/esm/universal/context.d.ts +122 -0
  252. package/esm/universal/context.d.ts.map +1 -0
  253. package/esm/universal/index.d.ts +57 -0
  254. package/esm/universal/index.d.ts.map +1 -0
  255. package/esm/universal/index.js +1755 -0
  256. package/esm/universal/renderers/html.renderer.d.ts +37 -0
  257. package/esm/universal/renderers/html.renderer.d.ts.map +1 -0
  258. package/esm/universal/renderers/index.d.ts +112 -0
  259. package/esm/universal/renderers/index.d.ts.map +1 -0
  260. package/esm/universal/renderers/markdown.renderer.d.ts +33 -0
  261. package/esm/universal/renderers/markdown.renderer.d.ts.map +1 -0
  262. package/esm/universal/renderers/mdx.renderer.d.ts +38 -0
  263. package/esm/universal/renderers/mdx.renderer.d.ts.map +1 -0
  264. package/esm/universal/renderers/react.renderer.d.ts +46 -0
  265. package/esm/universal/renderers/react.renderer.d.ts.map +1 -0
  266. package/esm/universal/runtime-builder.d.ts +33 -0
  267. package/esm/universal/runtime-builder.d.ts.map +1 -0
  268. package/esm/universal/store.d.ts +135 -0
  269. package/esm/universal/store.d.ts.map +1 -0
  270. package/esm/universal/types.d.ts +199 -0
  271. package/esm/universal/types.d.ts.map +1 -0
  272. package/esm/web-components/core/attribute-parser.d.ts +82 -0
  273. package/esm/web-components/core/attribute-parser.d.ts.map +1 -0
  274. package/esm/web-components/core/base-element.d.ts +197 -0
  275. package/esm/web-components/core/base-element.d.ts.map +1 -0
  276. package/esm/web-components/core/index.d.ts +9 -0
  277. package/esm/web-components/core/index.d.ts.map +1 -0
  278. package/esm/web-components/elements/fmcp-alert.d.ts +46 -0
  279. package/esm/web-components/elements/fmcp-alert.d.ts.map +1 -0
  280. package/esm/web-components/elements/fmcp-badge.d.ts +47 -0
  281. package/esm/web-components/elements/fmcp-badge.d.ts.map +1 -0
  282. package/esm/web-components/elements/fmcp-button.d.ts +117 -0
  283. package/esm/web-components/elements/fmcp-button.d.ts.map +1 -0
  284. package/esm/web-components/elements/fmcp-card.d.ts +53 -0
  285. package/esm/web-components/elements/fmcp-card.d.ts.map +1 -0
  286. package/esm/web-components/elements/fmcp-input.d.ts +96 -0
  287. package/esm/web-components/elements/fmcp-input.d.ts.map +1 -0
  288. package/esm/web-components/elements/fmcp-select.d.ts +100 -0
  289. package/esm/web-components/elements/fmcp-select.d.ts.map +1 -0
  290. package/esm/web-components/elements/index.d.ts +13 -0
  291. package/esm/web-components/elements/index.d.ts.map +1 -0
  292. package/esm/web-components/index.d.ts +50 -0
  293. package/esm/web-components/index.d.ts.map +1 -0
  294. package/esm/web-components/index.js +1993 -0
  295. package/esm/web-components/register.d.ts +57 -0
  296. package/esm/web-components/register.d.ts.map +1 -0
  297. package/esm/web-components/types.d.ts +122 -0
  298. package/esm/web-components/types.d.ts.map +1 -0
  299. package/esm/widgets/index.d.ts +8 -0
  300. package/esm/widgets/index.d.ts.map +1 -0
  301. package/esm/widgets/index.js +883 -0
  302. package/esm/widgets/progress.d.ts +133 -0
  303. package/esm/widgets/progress.d.ts.map +1 -0
  304. package/esm/widgets/resource.d.ts +163 -0
  305. package/esm/widgets/resource.d.ts.map +1 -0
  306. package/index.d.ts +40 -0
  307. package/index.d.ts.map +1 -0
  308. package/index.js +8526 -0
  309. package/layouts/base.d.ts +86 -0
  310. package/layouts/base.d.ts.map +1 -0
  311. package/layouts/index.d.ts +8 -0
  312. package/layouts/index.d.ts.map +1 -0
  313. package/layouts/index.js +437 -0
  314. package/layouts/presets.d.ts +134 -0
  315. package/layouts/presets.d.ts.map +1 -0
  316. package/package.json +33 -110
  317. package/pages/consent.d.ts +117 -0
  318. package/pages/consent.d.ts.map +1 -0
  319. package/pages/error.d.ts +101 -0
  320. package/pages/error.d.ts.map +1 -0
  321. package/pages/index.d.ts +9 -0
  322. package/pages/index.d.ts.map +1 -0
  323. package/pages/index.js +1065 -0
  324. package/react/Alert.d.ts +101 -0
  325. package/react/Alert.d.ts.map +1 -0
  326. package/react/Badge.d.ts +100 -0
  327. package/react/Badge.d.ts.map +1 -0
  328. package/react/Button.d.ts +108 -0
  329. package/react/Button.d.ts.map +1 -0
  330. package/react/Card.d.ts +103 -0
  331. package/react/Card.d.ts.map +1 -0
  332. package/react/hooks/context.d.ts +179 -0
  333. package/react/hooks/context.d.ts.map +1 -0
  334. package/react/hooks/index.d.ts +42 -0
  335. package/react/hooks/index.d.ts.map +1 -0
  336. package/react/hooks/tools.d.ts +284 -0
  337. package/react/hooks/tools.d.ts.map +1 -0
  338. package/react/index.d.ts +80 -0
  339. package/react/index.d.ts.map +1 -0
  340. package/react/index.js +3160 -0
  341. package/react/types.d.ts +105 -0
  342. package/react/types.d.ts.map +1 -0
  343. package/react/utils.d.ts +43 -0
  344. package/react/utils.d.ts.map +1 -0
  345. package/render/index.d.ts +8 -0
  346. package/render/index.d.ts.map +1 -0
  347. package/render/index.js +77 -0
  348. package/render/prerender.d.ts +57 -0
  349. package/render/prerender.d.ts.map +1 -0
  350. package/renderers/index.d.ts +21 -0
  351. package/renderers/index.d.ts.map +1 -0
  352. package/renderers/index.js +416 -0
  353. package/renderers/react.adapter.d.ts +70 -0
  354. package/renderers/react.adapter.d.ts.map +1 -0
  355. package/renderers/react.renderer.d.ts +96 -0
  356. package/renderers/react.renderer.d.ts.map +1 -0
  357. package/universal/UniversalApp.d.ts +108 -0
  358. package/universal/UniversalApp.d.ts.map +1 -0
  359. package/universal/cached-runtime.d.ts +115 -0
  360. package/universal/cached-runtime.d.ts.map +1 -0
  361. package/universal/context.d.ts +122 -0
  362. package/universal/context.d.ts.map +1 -0
  363. package/universal/index.d.ts +57 -0
  364. package/universal/index.d.ts.map +1 -0
  365. package/universal/index.js +1841 -0
  366. package/universal/renderers/html.renderer.d.ts +37 -0
  367. package/universal/renderers/html.renderer.d.ts.map +1 -0
  368. package/universal/renderers/index.d.ts +112 -0
  369. package/universal/renderers/index.d.ts.map +1 -0
  370. package/universal/renderers/markdown.renderer.d.ts +33 -0
  371. package/universal/renderers/markdown.renderer.d.ts.map +1 -0
  372. package/universal/renderers/mdx.renderer.d.ts +38 -0
  373. package/universal/renderers/mdx.renderer.d.ts.map +1 -0
  374. package/universal/renderers/react.renderer.d.ts +46 -0
  375. package/universal/renderers/react.renderer.d.ts.map +1 -0
  376. package/universal/runtime-builder.d.ts +33 -0
  377. package/universal/runtime-builder.d.ts.map +1 -0
  378. package/universal/store.d.ts +135 -0
  379. package/universal/store.d.ts.map +1 -0
  380. package/universal/types.d.ts +199 -0
  381. package/universal/types.d.ts.map +1 -0
  382. package/web-components/core/attribute-parser.d.ts +82 -0
  383. package/web-components/core/attribute-parser.d.ts.map +1 -0
  384. package/web-components/core/base-element.d.ts +197 -0
  385. package/web-components/core/base-element.d.ts.map +1 -0
  386. package/web-components/core/index.d.ts +9 -0
  387. package/web-components/core/index.d.ts.map +1 -0
  388. package/web-components/elements/fmcp-alert.d.ts +46 -0
  389. package/web-components/elements/fmcp-alert.d.ts.map +1 -0
  390. package/web-components/elements/fmcp-badge.d.ts +47 -0
  391. package/web-components/elements/fmcp-badge.d.ts.map +1 -0
  392. package/web-components/elements/fmcp-button.d.ts +117 -0
  393. package/web-components/elements/fmcp-button.d.ts.map +1 -0
  394. package/web-components/elements/fmcp-card.d.ts +53 -0
  395. package/web-components/elements/fmcp-card.d.ts.map +1 -0
  396. package/web-components/elements/fmcp-input.d.ts +96 -0
  397. package/web-components/elements/fmcp-input.d.ts.map +1 -0
  398. package/web-components/elements/fmcp-select.d.ts +100 -0
  399. package/web-components/elements/fmcp-select.d.ts.map +1 -0
  400. package/web-components/elements/index.d.ts +13 -0
  401. package/web-components/elements/index.d.ts.map +1 -0
  402. package/web-components/index.d.ts +50 -0
  403. package/web-components/index.d.ts.map +1 -0
  404. package/web-components/index.js +2028 -0
  405. package/web-components/register.d.ts +57 -0
  406. package/web-components/register.d.ts.map +1 -0
  407. package/web-components/types.d.ts +122 -0
  408. package/web-components/types.d.ts.map +1 -0
  409. package/widgets/index.d.ts +8 -0
  410. package/widgets/index.d.ts.map +1 -0
  411. package/widgets/index.js +910 -0
  412. package/widgets/progress.d.ts +133 -0
  413. package/widgets/progress.d.ts.map +1 -0
  414. package/widgets/resource.d.ts +163 -0
  415. package/widgets/resource.d.ts.map +1 -0
  416. package/src/adapters/index.d.ts +0 -10
  417. package/src/adapters/index.js +0 -18
  418. package/src/adapters/index.js.map +0 -1
  419. package/src/adapters/platform-meta.d.ts +0 -165
  420. package/src/adapters/platform-meta.js +0 -310
  421. package/src/adapters/platform-meta.js.map +0 -1
  422. package/src/base-template/bridge.d.ts +0 -89
  423. package/src/base-template/bridge.js +0 -452
  424. package/src/base-template/bridge.js.map +0 -1
  425. package/src/base-template/default-base-template.d.ts +0 -91
  426. package/src/base-template/default-base-template.js +0 -435
  427. package/src/base-template/default-base-template.js.map +0 -1
  428. package/src/base-template/index.d.ts +0 -14
  429. package/src/base-template/index.js +0 -30
  430. package/src/base-template/index.js.map +0 -1
  431. package/src/base-template/polyfills.d.ts +0 -30
  432. package/src/base-template/polyfills.js +0 -190
  433. package/src/base-template/polyfills.js.map +0 -1
  434. package/src/base-template/theme-styles.d.ts +0 -73
  435. package/src/base-template/theme-styles.js +0 -95
  436. package/src/base-template/theme-styles.js.map +0 -1
  437. package/src/bridge/adapters/base-adapter.d.ts +0 -103
  438. package/src/bridge/adapters/base-adapter.js +0 -314
  439. package/src/bridge/adapters/base-adapter.js.map +0 -1
  440. package/src/bridge/adapters/claude.adapter.d.ts +0 -66
  441. package/src/bridge/adapters/claude.adapter.js +0 -145
  442. package/src/bridge/adapters/claude.adapter.js.map +0 -1
  443. package/src/bridge/adapters/ext-apps.adapter.d.ts +0 -142
  444. package/src/bridge/adapters/ext-apps.adapter.js +0 -416
  445. package/src/bridge/adapters/ext-apps.adapter.js.map +0 -1
  446. package/src/bridge/adapters/gemini.adapter.d.ts +0 -63
  447. package/src/bridge/adapters/gemini.adapter.js +0 -160
  448. package/src/bridge/adapters/gemini.adapter.js.map +0 -1
  449. package/src/bridge/adapters/generic.adapter.d.ts +0 -55
  450. package/src/bridge/adapters/generic.adapter.js +0 -108
  451. package/src/bridge/adapters/generic.adapter.js.map +0 -1
  452. package/src/bridge/adapters/index.d.ts +0 -25
  453. package/src/bridge/adapters/index.js +0 -65
  454. package/src/bridge/adapters/index.js.map +0 -1
  455. package/src/bridge/adapters/openai.adapter.d.ts +0 -64
  456. package/src/bridge/adapters/openai.adapter.js +0 -194
  457. package/src/bridge/adapters/openai.adapter.js.map +0 -1
  458. package/src/bridge/core/adapter-registry.d.ts +0 -121
  459. package/src/bridge/core/adapter-registry.js +0 -271
  460. package/src/bridge/core/adapter-registry.js.map +0 -1
  461. package/src/bridge/core/bridge-factory.d.ts +0 -198
  462. package/src/bridge/core/bridge-factory.js +0 -428
  463. package/src/bridge/core/bridge-factory.js.map +0 -1
  464. package/src/bridge/core/index.d.ts +0 -9
  465. package/src/bridge/core/index.js +0 -22
  466. package/src/bridge/core/index.js.map +0 -1
  467. package/src/bridge/index.d.ts +0 -61
  468. package/src/bridge/index.js +0 -94
  469. package/src/bridge/index.js.map +0 -1
  470. package/src/bridge/runtime/iife-generator.d.ts +0 -61
  471. package/src/bridge/runtime/iife-generator.js +0 -940
  472. package/src/bridge/runtime/iife-generator.js.map +0 -1
  473. package/src/bridge/runtime/index.d.ts +0 -8
  474. package/src/bridge/runtime/index.js +0 -16
  475. package/src/bridge/runtime/index.js.map +0 -1
  476. package/src/bridge/types.d.ts +0 -385
  477. package/src/bridge/types.js +0 -11
  478. package/src/bridge/types.js.map +0 -1
  479. package/src/build/cdn-resources.d.ts +0 -140
  480. package/src/build/cdn-resources.js +0 -314
  481. package/src/build/cdn-resources.js.map +0 -1
  482. package/src/build/index.d.ts +0 -294
  483. package/src/build/index.js +0 -325
  484. package/src/build/index.js.map +0 -1
  485. package/src/build/widget-manifest.d.ts +0 -212
  486. package/src/build/widget-manifest.js +0 -652
  487. package/src/build/widget-manifest.js.map +0 -1
  488. package/src/bundler/bundler.d.ts +0 -110
  489. package/src/bundler/bundler.js +0 -432
  490. package/src/bundler/bundler.js.map +0 -1
  491. package/src/bundler/cache.d.ts +0 -172
  492. package/src/bundler/cache.js +0 -250
  493. package/src/bundler/cache.js.map +0 -1
  494. package/src/bundler/index.d.ts +0 -41
  495. package/src/bundler/index.js +0 -73
  496. package/src/bundler/index.js.map +0 -1
  497. package/src/bundler/sandbox/enclave-adapter.d.ts +0 -120
  498. package/src/bundler/sandbox/enclave-adapter.js +0 -339
  499. package/src/bundler/sandbox/enclave-adapter.js.map +0 -1
  500. package/src/bundler/sandbox/executor.d.ts +0 -13
  501. package/src/bundler/sandbox/executor.js +0 -22
  502. package/src/bundler/sandbox/executor.js.map +0 -1
  503. package/src/bundler/sandbox/policy.d.ts +0 -61
  504. package/src/bundler/sandbox/policy.js +0 -238
  505. package/src/bundler/sandbox/policy.js.map +0 -1
  506. package/src/bundler/types.d.ts +0 -347
  507. package/src/bundler/types.js +0 -132
  508. package/src/bundler/types.js.map +0 -1
  509. package/src/components/alert.d.ts +0 -71
  510. package/src/components/alert.js +0 -189
  511. package/src/components/alert.js.map +0 -1
  512. package/src/components/alert.schema.d.ts +0 -114
  513. package/src/components/alert.schema.js +0 -105
  514. package/src/components/alert.schema.js.map +0 -1
  515. package/src/components/avatar.d.ts +0 -76
  516. package/src/components/avatar.js +0 -176
  517. package/src/components/avatar.js.map +0 -1
  518. package/src/components/avatar.schema.d.ts +0 -169
  519. package/src/components/avatar.schema.js +0 -103
  520. package/src/components/avatar.schema.js.map +0 -1
  521. package/src/components/badge.d.ts +0 -70
  522. package/src/components/badge.js +0 -149
  523. package/src/components/badge.js.map +0 -1
  524. package/src/components/badge.schema.d.ts +0 -109
  525. package/src/components/badge.schema.js +0 -96
  526. package/src/components/badge.schema.js.map +0 -1
  527. package/src/components/button.d.ts +0 -111
  528. package/src/components/button.js +0 -336
  529. package/src/components/button.js.map +0 -1
  530. package/src/components/button.schema.d.ts +0 -148
  531. package/src/components/button.schema.js +0 -121
  532. package/src/components/button.schema.js.map +0 -1
  533. package/src/components/card.d.ts +0 -60
  534. package/src/components/card.js +0 -117
  535. package/src/components/card.js.map +0 -1
  536. package/src/components/card.schema.d.ts +0 -113
  537. package/src/components/card.schema.js +0 -98
  538. package/src/components/card.schema.js.map +0 -1
  539. package/src/components/form.d.ts +0 -239
  540. package/src/components/form.js +0 -420
  541. package/src/components/form.js.map +0 -1
  542. package/src/components/form.schema.d.ts +0 -441
  543. package/src/components/form.schema.js +0 -406
  544. package/src/components/form.schema.js.map +0 -1
  545. package/src/components/index.d.ts +0 -29
  546. package/src/components/index.js +0 -98
  547. package/src/components/index.js.map +0 -1
  548. package/src/components/list.d.ts +0 -127
  549. package/src/components/list.js +0 -279
  550. package/src/components/list.js.map +0 -1
  551. package/src/components/list.schema.d.ts +0 -134
  552. package/src/components/list.schema.js +0 -168
  553. package/src/components/list.schema.js.map +0 -1
  554. package/src/components/modal.d.ts +0 -111
  555. package/src/components/modal.js +0 -260
  556. package/src/components/modal.js.map +0 -1
  557. package/src/components/modal.schema.d.ts +0 -186
  558. package/src/components/modal.schema.js +0 -167
  559. package/src/components/modal.schema.js.map +0 -1
  560. package/src/components/table.d.ts +0 -105
  561. package/src/components/table.js +0 -283
  562. package/src/components/table.js.map +0 -1
  563. package/src/components/table.schema.d.ts +0 -159
  564. package/src/components/table.schema.js +0 -173
  565. package/src/components/table.schema.js.map +0 -1
  566. package/src/handlebars/helpers.d.ts +0 -348
  567. package/src/handlebars/helpers.js +0 -605
  568. package/src/handlebars/helpers.js.map +0 -1
  569. package/src/handlebars/index.d.ts +0 -193
  570. package/src/handlebars/index.js +0 -350
  571. package/src/handlebars/index.js.map +0 -1
  572. package/src/index.d.ts +0 -50
  573. package/src/index.js +0 -192
  574. package/src/index.js.map +0 -1
  575. package/src/layouts/base.d.ts +0 -88
  576. package/src/layouts/base.js +0 -227
  577. package/src/layouts/base.js.map +0 -1
  578. package/src/layouts/index.d.ts +0 -7
  579. package/src/layouts/index.js +0 -25
  580. package/src/layouts/index.js.map +0 -1
  581. package/src/layouts/presets.d.ts +0 -133
  582. package/src/layouts/presets.js +0 -277
  583. package/src/layouts/presets.js.map +0 -1
  584. package/src/pages/consent.d.ts +0 -116
  585. package/src/pages/consent.js +0 -218
  586. package/src/pages/consent.js.map +0 -1
  587. package/src/pages/error.d.ts +0 -100
  588. package/src/pages/error.js +0 -263
  589. package/src/pages/error.js.map +0 -1
  590. package/src/pages/index.d.ts +0 -8
  591. package/src/pages/index.js +0 -27
  592. package/src/pages/index.js.map +0 -1
  593. package/src/react/Alert.d.ts +0 -101
  594. package/src/react/Alert.js +0 -51
  595. package/src/react/Alert.js.map +0 -1
  596. package/src/react/Badge.d.ts +0 -100
  597. package/src/react/Badge.js +0 -55
  598. package/src/react/Badge.js.map +0 -1
  599. package/src/react/Button.d.ts +0 -108
  600. package/src/react/Button.js +0 -52
  601. package/src/react/Button.js.map +0 -1
  602. package/src/react/Card.d.ts +0 -103
  603. package/src/react/Card.js +0 -55
  604. package/src/react/Card.js.map +0 -1
  605. package/src/react/hooks/context.d.ts +0 -178
  606. package/src/react/hooks/context.js +0 -287
  607. package/src/react/hooks/context.js.map +0 -1
  608. package/src/react/hooks/index.d.ts +0 -41
  609. package/src/react/hooks/index.js +0 -61
  610. package/src/react/hooks/index.js.map +0 -1
  611. package/src/react/hooks/tools.d.ts +0 -283
  612. package/src/react/hooks/tools.js +0 -465
  613. package/src/react/hooks/tools.js.map +0 -1
  614. package/src/react/index.d.ts +0 -80
  615. package/src/react/index.js +0 -113
  616. package/src/react/index.js.map +0 -1
  617. package/src/react/types.d.ts +0 -105
  618. package/src/react/types.js +0 -12
  619. package/src/react/types.js.map +0 -1
  620. package/src/react/utils.d.ts +0 -42
  621. package/src/react/utils.js +0 -99
  622. package/src/react/utils.js.map +0 -1
  623. package/src/registry/index.d.ts +0 -45
  624. package/src/registry/index.js +0 -67
  625. package/src/registry/index.js.map +0 -1
  626. package/src/registry/render-template.d.ts +0 -86
  627. package/src/registry/render-template.js +0 -239
  628. package/src/registry/render-template.js.map +0 -1
  629. package/src/registry/tool-ui.registry.d.ts +0 -260
  630. package/src/registry/tool-ui.registry.js +0 -438
  631. package/src/registry/tool-ui.registry.js.map +0 -1
  632. package/src/registry/uri-utils.d.ts +0 -55
  633. package/src/registry/uri-utils.js +0 -97
  634. package/src/registry/uri-utils.js.map +0 -1
  635. package/src/render/index.d.ts +0 -7
  636. package/src/render/index.js +0 -14
  637. package/src/render/index.js.map +0 -1
  638. package/src/render/prerender.d.ts +0 -56
  639. package/src/render/prerender.js +0 -98
  640. package/src/render/prerender.js.map +0 -1
  641. package/src/renderers/cache.d.ts +0 -144
  642. package/src/renderers/cache.js +0 -240
  643. package/src/renderers/cache.js.map +0 -1
  644. package/src/renderers/html.renderer.d.ts +0 -122
  645. package/src/renderers/html.renderer.js +0 -204
  646. package/src/renderers/html.renderer.js.map +0 -1
  647. package/src/renderers/index.d.ts +0 -35
  648. package/src/renderers/index.js +0 -70
  649. package/src/renderers/index.js.map +0 -1
  650. package/src/renderers/mdx.renderer.d.ts +0 -119
  651. package/src/renderers/mdx.renderer.js +0 -305
  652. package/src/renderers/mdx.renderer.js.map +0 -1
  653. package/src/renderers/react.renderer.d.ts +0 -95
  654. package/src/renderers/react.renderer.js +0 -260
  655. package/src/renderers/react.renderer.js.map +0 -1
  656. package/src/renderers/registry.d.ts +0 -133
  657. package/src/renderers/registry.js +0 -232
  658. package/src/renderers/registry.js.map +0 -1
  659. package/src/renderers/types.d.ts +0 -341
  660. package/src/renderers/types.js +0 -9
  661. package/src/renderers/types.js.map +0 -1
  662. package/src/renderers/utils/detect.d.ts +0 -106
  663. package/src/renderers/utils/detect.js +0 -267
  664. package/src/renderers/utils/detect.js.map +0 -1
  665. package/src/renderers/utils/hash.d.ts +0 -39
  666. package/src/renderers/utils/hash.js +0 -75
  667. package/src/renderers/utils/hash.js.map +0 -1
  668. package/src/renderers/utils/index.d.ts +0 -8
  669. package/src/renderers/utils/index.js +0 -28
  670. package/src/renderers/utils/index.js.map +0 -1
  671. package/src/renderers/utils/transpiler.d.ts +0 -88
  672. package/src/renderers/utils/transpiler.js +0 -215
  673. package/src/renderers/utils/transpiler.js.map +0 -1
  674. package/src/runtime/adapters/html.adapter.d.ts +0 -58
  675. package/src/runtime/adapters/html.adapter.js +0 -131
  676. package/src/runtime/adapters/html.adapter.js.map +0 -1
  677. package/src/runtime/adapters/index.d.ts +0 -25
  678. package/src/runtime/adapters/index.js +0 -54
  679. package/src/runtime/adapters/index.js.map +0 -1
  680. package/src/runtime/adapters/mdx.adapter.d.ts +0 -72
  681. package/src/runtime/adapters/mdx.adapter.js +0 -241
  682. package/src/runtime/adapters/mdx.adapter.js.map +0 -1
  683. package/src/runtime/adapters/react.adapter.d.ts +0 -69
  684. package/src/runtime/adapters/react.adapter.js +0 -245
  685. package/src/runtime/adapters/react.adapter.js.map +0 -1
  686. package/src/runtime/adapters/types.d.ts +0 -94
  687. package/src/runtime/adapters/types.js +0 -11
  688. package/src/runtime/adapters/types.js.map +0 -1
  689. package/src/runtime/csp.d.ts +0 -37
  690. package/src/runtime/csp.js +0 -140
  691. package/src/runtime/csp.js.map +0 -1
  692. package/src/runtime/index.d.ts +0 -16
  693. package/src/runtime/index.js +0 -72
  694. package/src/runtime/index.js.map +0 -1
  695. package/src/runtime/mcp-bridge.d.ts +0 -100
  696. package/src/runtime/mcp-bridge.js +0 -581
  697. package/src/runtime/mcp-bridge.js.map +0 -1
  698. package/src/runtime/renderer-runtime.d.ts +0 -132
  699. package/src/runtime/renderer-runtime.js +0 -389
  700. package/src/runtime/renderer-runtime.js.map +0 -1
  701. package/src/runtime/sanitizer.d.ts +0 -171
  702. package/src/runtime/sanitizer.js +0 -318
  703. package/src/runtime/sanitizer.js.map +0 -1
  704. package/src/runtime/types.d.ts +0 -414
  705. package/src/runtime/types.js +0 -12
  706. package/src/runtime/types.js.map +0 -1
  707. package/src/runtime/wrapper.d.ts +0 -375
  708. package/src/runtime/wrapper.js +0 -1793
  709. package/src/runtime/wrapper.js.map +0 -1
  710. package/src/styles/index.d.ts +0 -7
  711. package/src/styles/index.js +0 -11
  712. package/src/styles/index.js.map +0 -1
  713. package/src/styles/variants.d.ts +0 -50
  714. package/src/styles/variants.js +0 -175
  715. package/src/styles/variants.js.map +0 -1
  716. package/src/theme/cdn.d.ts +0 -194
  717. package/src/theme/cdn.js +0 -375
  718. package/src/theme/cdn.js.map +0 -1
  719. package/src/theme/index.d.ts +0 -17
  720. package/src/theme/index.js +0 -57
  721. package/src/theme/index.js.map +0 -1
  722. package/src/theme/platforms.d.ts +0 -106
  723. package/src/theme/platforms.js +0 -161
  724. package/src/theme/platforms.js.map +0 -1
  725. package/src/theme/presets/github-openai.d.ts +0 -49
  726. package/src/theme/presets/github-openai.js +0 -189
  727. package/src/theme/presets/github-openai.js.map +0 -1
  728. package/src/theme/presets/index.d.ts +0 -10
  729. package/src/theme/presets/index.js +0 -17
  730. package/src/theme/presets/index.js.map +0 -1
  731. package/src/theme/theme.d.ts +0 -395
  732. package/src/theme/theme.js +0 -332
  733. package/src/theme/theme.js.map +0 -1
  734. package/src/tool-template/builder.d.ts +0 -212
  735. package/src/tool-template/builder.js +0 -397
  736. package/src/tool-template/builder.js.map +0 -1
  737. package/src/tool-template/index.d.ts +0 -15
  738. package/src/tool-template/index.js +0 -38
  739. package/src/tool-template/index.js.map +0 -1
  740. package/src/types/index.d.ts +0 -13
  741. package/src/types/index.js +0 -26
  742. package/src/types/index.js.map +0 -1
  743. package/src/types/ui-config.d.ts +0 -357
  744. package/src/types/ui-config.js +0 -12
  745. package/src/types/ui-config.js.map +0 -1
  746. package/src/types/ui-runtime.d.ts +0 -965
  747. package/src/types/ui-runtime.js +0 -117
  748. package/src/types/ui-runtime.js.map +0 -1
  749. package/src/validation/error-box.d.ts +0 -55
  750. package/src/validation/error-box.js +0 -75
  751. package/src/validation/error-box.js.map +0 -1
  752. package/src/validation/index.d.ts +0 -12
  753. package/src/validation/index.js +0 -21
  754. package/src/validation/index.js.map +0 -1
  755. package/src/validation/wrapper.d.ts +0 -96
  756. package/src/validation/wrapper.js +0 -117
  757. package/src/validation/wrapper.js.map +0 -1
  758. package/src/web-components/core/attribute-parser.d.ts +0 -85
  759. package/src/web-components/core/attribute-parser.js +0 -189
  760. package/src/web-components/core/attribute-parser.js.map +0 -1
  761. package/src/web-components/core/base-element.d.ts +0 -197
  762. package/src/web-components/core/base-element.js +0 -289
  763. package/src/web-components/core/base-element.js.map +0 -1
  764. package/src/web-components/core/index.d.ts +0 -8
  765. package/src/web-components/core/index.js +0 -18
  766. package/src/web-components/core/index.js.map +0 -1
  767. package/src/web-components/elements/fmcp-alert.d.ts +0 -45
  768. package/src/web-components/elements/fmcp-alert.js +0 -93
  769. package/src/web-components/elements/fmcp-alert.js.map +0 -1
  770. package/src/web-components/elements/fmcp-badge.d.ts +0 -46
  771. package/src/web-components/elements/fmcp-badge.js +0 -99
  772. package/src/web-components/elements/fmcp-badge.js.map +0 -1
  773. package/src/web-components/elements/fmcp-button.d.ts +0 -124
  774. package/src/web-components/elements/fmcp-button.js +0 -233
  775. package/src/web-components/elements/fmcp-button.js.map +0 -1
  776. package/src/web-components/elements/fmcp-card.d.ts +0 -52
  777. package/src/web-components/elements/fmcp-card.js +0 -115
  778. package/src/web-components/elements/fmcp-card.js.map +0 -1
  779. package/src/web-components/elements/fmcp-input.d.ts +0 -95
  780. package/src/web-components/elements/fmcp-input.js +0 -248
  781. package/src/web-components/elements/fmcp-input.js.map +0 -1
  782. package/src/web-components/elements/fmcp-select.d.ts +0 -99
  783. package/src/web-components/elements/fmcp-select.js +0 -243
  784. package/src/web-components/elements/fmcp-select.js.map +0 -1
  785. package/src/web-components/elements/index.d.ts +0 -12
  786. package/src/web-components/elements/index.js +0 -34
  787. package/src/web-components/elements/index.js.map +0 -1
  788. package/src/web-components/index.d.ts +0 -49
  789. package/src/web-components/index.js +0 -75
  790. package/src/web-components/index.js.map +0 -1
  791. package/src/web-components/register.d.ts +0 -56
  792. package/src/web-components/register.js +0 -80
  793. package/src/web-components/register.js.map +0 -1
  794. package/src/web-components/types.d.ts +0 -121
  795. package/src/web-components/types.js +0 -25
  796. package/src/web-components/types.js.map +0 -1
  797. package/src/widgets/index.d.ts +0 -7
  798. package/src/widgets/index.js +0 -24
  799. package/src/widgets/index.js.map +0 -1
  800. package/src/widgets/progress.d.ts +0 -132
  801. package/src/widgets/progress.js +0 -303
  802. package/src/widgets/progress.js.map +0 -1
  803. package/src/widgets/resource.d.ts +0 -162
  804. package/src/widgets/resource.js +0 -340
  805. package/src/widgets/resource.js.map +0 -1
@@ -0,0 +1,3707 @@
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/bundler/bundler.ts
1461
+ var import_utils = require("@frontmcp/uipack/utils");
1462
+
1463
+ // libs/ui/src/universal/types.ts
1464
+ var UNIVERSAL_CDN = {
1465
+ esm: {
1466
+ reactMarkdown: "https://esm.sh/react-markdown@9",
1467
+ mdxReact: "https://esm.sh/@mdx-js/react@3",
1468
+ remarkGfm: "https://esm.sh/remark-gfm@4"
1469
+ }
1470
+ // Note: These libraries are not available on cdnjs
1471
+ // For Claude, we use inline implementations
1472
+ };
1473
+ function detectContentType(source) {
1474
+ if (typeof source === "function") {
1475
+ return "react";
1476
+ }
1477
+ if (typeof source !== "string") {
1478
+ return "html";
1479
+ }
1480
+ 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
1481
+ /^function\s+\w+\s*\(/m.test(source);
1482
+ const hasJsxTags = /<[A-Z][a-zA-Z]*/.test(source);
1483
+ const hasMarkdown = /^#{1,6}\s/m.test(source) || /^\*\s/m.test(source) || /^-\s/m.test(source) || /^\d+\.\s/m.test(source);
1484
+ if (hasModuleSyntax && hasJsxTags) {
1485
+ return "react";
1486
+ }
1487
+ if (hasJsxTags && hasMarkdown && !hasModuleSyntax) {
1488
+ return "mdx";
1489
+ }
1490
+ if (hasMarkdown || /\*\*[^*]+\*\*/.test(source) || /\[[^\]]+\]\([^)]+\)/.test(source)) {
1491
+ return "markdown";
1492
+ }
1493
+ if (hasJsxTags && !hasModuleSyntax) {
1494
+ return "mdx";
1495
+ }
1496
+ return "html";
1497
+ }
1498
+
1499
+ // libs/ui/src/universal/cached-runtime.ts
1500
+ var RUNTIME_PLACEHOLDERS = {
1501
+ /** Placeholder for transpiled component code */
1502
+ COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/",
1503
+ /** Placeholder for data injection */
1504
+ DATA_INJECTION: "/*__FRONTMCP_DATA_INJECTION__*/",
1505
+ /** Placeholder for custom components */
1506
+ CUSTOM_COMPONENTS: "/*__FRONTMCP_CUSTOM_COMPONENTS__*/"
1507
+ };
1508
+ var runtimeCache = /* @__PURE__ */ new Map();
1509
+ var DEFAULT_CACHE_CONFIG = {
1510
+ maxEntries: 10,
1511
+ ttl: 0
1512
+ // Forever by default
1513
+ };
1514
+ function generateCacheKey(options) {
1515
+ const securityKey = options.contentSecurity ? [
1516
+ options.contentSecurity.allowUnsafeLinks ? "unsafeLinks" : "",
1517
+ options.contentSecurity.allowInlineScripts ? "unsafeScripts" : "",
1518
+ options.contentSecurity.bypassSanitization ? "bypass" : ""
1519
+ ].filter(Boolean).join("+") || "secure" : "secure";
1520
+ return [
1521
+ options.cdnType,
1522
+ options.includeMarkdown ? "md" : "",
1523
+ options.includeMdx ? "mdx" : "",
1524
+ options.minify ? "min" : "",
1525
+ securityKey
1526
+ ].filter(Boolean).join(":");
1527
+ }
1528
+ function buildStoreRuntime() {
1529
+ return `
1530
+ // FrontMCP Store (Vendor)
1531
+ (function() {
1532
+ var state = {
1533
+ toolName: null,
1534
+ input: null,
1535
+ output: null,
1536
+ content: null,
1537
+ structuredContent: null,
1538
+ loading: false,
1539
+ error: null
1540
+ };
1541
+
1542
+ var listeners = new Set();
1543
+
1544
+ window.__frontmcp = {
1545
+ getState: function() { return state; },
1546
+ setState: function(partial) {
1547
+ state = Object.assign({}, state, partial);
1548
+ listeners.forEach(function(fn) { fn(); });
1549
+ },
1550
+ subscribe: function(fn) {
1551
+ listeners.add(fn);
1552
+ return function() { listeners.delete(fn); };
1553
+ },
1554
+ reset: function() {
1555
+ state = {
1556
+ toolName: null,
1557
+ input: null,
1558
+ output: null,
1559
+ content: null,
1560
+ structuredContent: null,
1561
+ loading: false,
1562
+ error: null
1563
+ };
1564
+ },
1565
+ context: state,
1566
+ setContext: function(ctx) {
1567
+ this.setState(ctx);
1568
+ }
1569
+ };
1570
+
1571
+ // React hooks
1572
+ window.useFrontMCPStore = function() {
1573
+ var store = window.__frontmcp;
1574
+ return React.useSyncExternalStore(
1575
+ store.subscribe,
1576
+ store.getState,
1577
+ store.getState
1578
+ );
1579
+ };
1580
+
1581
+ window.useToolOutput = function() {
1582
+ return window.useFrontMCPStore().output;
1583
+ };
1584
+
1585
+ window.useToolInput = function() {
1586
+ return window.useFrontMCPStore().input;
1587
+ };
1588
+
1589
+ window.useContent = function() {
1590
+ return window.useFrontMCPStore().content;
1591
+ };
1592
+ })();
1593
+ `;
1594
+ }
1595
+ function buildRequireShim() {
1596
+ return `
1597
+ // Module Require Shim (Vendor)
1598
+ (function() {
1599
+ window.__moduleCache = {};
1600
+ window.require = function(moduleName) {
1601
+ if (window.__moduleCache[moduleName]) {
1602
+ return window.__moduleCache[moduleName];
1603
+ }
1604
+
1605
+ var moduleMap = {
1606
+ 'react': function() { return window.React; },
1607
+ 'react-dom': function() { return window.ReactDOM; },
1608
+ 'react-dom/client': function() { return window.ReactDOM; },
1609
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
1610
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
1611
+ '@frontmcp/ui': function() { return window.frontmcp_ui_namespaceObject; },
1612
+ '@frontmcp/ui/react': function() { return window.frontmcp_ui_namespaceObject; }
1613
+ };
1614
+
1615
+ var resolver = moduleMap[moduleName];
1616
+ if (resolver) {
1617
+ var mod = resolver();
1618
+ window.__moduleCache[moduleName] = mod;
1619
+ return mod;
1620
+ }
1621
+
1622
+ console.warn('[FrontMCP] Unknown module:', moduleName);
1623
+ return {};
1624
+ };
1625
+ })();
1626
+ `;
1627
+ }
1628
+ function buildInlineMarkdownParser(options) {
1629
+ const allowUnsafeLinks = options?.contentSecurity?.bypassSanitization || options?.contentSecurity?.allowUnsafeLinks;
1630
+ return `
1631
+ // Inline Markdown Parser (Vendor)
1632
+ (function() {
1633
+ // XSS protection settings (configured at build time)
1634
+ // Set to true if contentSecurity.allowUnsafeLinks or bypassSanitization is enabled
1635
+ var __allowUnsafeLinks = ${allowUnsafeLinks ? "true" : "false"};
1636
+
1637
+ // URL scheme validation to prevent XSS via javascript: URLs
1638
+ function isSafeUrl(url) {
1639
+ // If unsafe links are explicitly allowed, skip validation
1640
+ if (__allowUnsafeLinks) return true;
1641
+ if (!url) return false;
1642
+ var lower = url.toLowerCase().trim();
1643
+ return lower.startsWith('http://') ||
1644
+ lower.startsWith('https://') ||
1645
+ lower.startsWith('/') ||
1646
+ lower.startsWith('#') ||
1647
+ lower.startsWith('mailto:');
1648
+ }
1649
+
1650
+ function parseMarkdown(md) {
1651
+ var html = md;
1652
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1653
+ html = html.replace(/^######\\s+(.*)$/gm, '<h6>$1</h6>');
1654
+ html = html.replace(/^#####\\s+(.*)$/gm, '<h5>$1</h5>');
1655
+ html = html.replace(/^####\\s+(.*)$/gm, '<h4>$1</h4>');
1656
+ html = html.replace(/^###\\s+(.*)$/gm, '<h3>$1</h3>');
1657
+ html = html.replace(/^##\\s+(.*)$/gm, '<h2>$1</h2>');
1658
+ html = html.replace(/^#\\s+(.*)$/gm, '<h1>$1</h1>');
1659
+ html = html.replace(/\\*\\*\\*(.+?)\\*\\*\\*/g, '<strong><em>$1</em></strong>');
1660
+ html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');
1661
+ html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');
1662
+ html = html.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
1663
+ // Links - validate URL scheme to prevent XSS (unless bypassed)
1664
+ html = html.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, function(match, text, url) {
1665
+ return isSafeUrl(url) ? '<a href="' + url + '">' + text + '</a>' : text;
1666
+ });
1667
+ html = html.replace(/^[-*]\\s+(.*)$/gm, '<li>$1</li>');
1668
+ html = html.replace(/\\n\\n+/g, '</p><p>');
1669
+ html = '<p>' + html + '</p>';
1670
+ return html;
1671
+ }
1672
+
1673
+ window.__frontmcp.parseMarkdown = parseMarkdown;
1674
+
1675
+ window.ReactMarkdown = function(props) {
1676
+ var html = parseMarkdown(props.children || '');
1677
+ return React.createElement('div', {
1678
+ className: 'frontmcp-markdown prose',
1679
+ dangerouslySetInnerHTML: { __html: html }
1680
+ });
1681
+ };
1682
+ })();
1683
+ `;
1684
+ }
1685
+ function buildRenderersRuntime(options) {
1686
+ const bypassSanitization = options?.contentSecurity?.bypassSanitization;
1687
+ const allowInlineScripts = bypassSanitization || options?.contentSecurity?.allowInlineScripts;
1688
+ return `
1689
+ // Universal Renderers (Vendor)
1690
+ (function() {
1691
+ var renderers = {};
1692
+
1693
+ // XSS protection settings (configured at build time)
1694
+ // Set to true if contentSecurity.allowInlineScripts or bypassSanitization is enabled
1695
+ var __allowInlineScripts = ${allowInlineScripts ? "true" : "false"};
1696
+
1697
+ renderers.html = {
1698
+ type: 'html',
1699
+ priority: 0,
1700
+ canHandle: function(c) { return c.type === 'html'; },
1701
+ render: function(c, ctx) {
1702
+ var html = c.source;
1703
+ // Apply XSS protection unless bypassed
1704
+ if (!__allowInlineScripts) {
1705
+ // Remove script tags and event handlers to prevent XSS
1706
+ html = html.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');
1707
+ html = html.replace(/\\s+on\\w+\\s*=/gi, ' data-removed-handler=');
1708
+ }
1709
+ return React.createElement('div', {
1710
+ className: 'frontmcp-html-content',
1711
+ dangerouslySetInnerHTML: { __html: html }
1712
+ });
1713
+ }
1714
+ };
1715
+
1716
+ renderers.markdown = {
1717
+ type: 'markdown',
1718
+ priority: 10,
1719
+ canHandle: function(c) {
1720
+ if (c.type === 'markdown') return true;
1721
+ if (typeof c.source !== 'string') return false;
1722
+ var s = c.source;
1723
+ return /^#{1,6}\\s/m.test(s) || /^[-*]\\s/m.test(s) || /\\*\\*[^*]+\\*\\*/.test(s);
1724
+ },
1725
+ render: function(c, ctx) {
1726
+ if (window.ReactMarkdown) {
1727
+ return React.createElement(window.ReactMarkdown, {
1728
+ children: c.source,
1729
+ components: Object.assign({}, ctx.components, c.components)
1730
+ });
1731
+ }
1732
+ var html = window.__frontmcp.parseMarkdown ? window.__frontmcp.parseMarkdown(c.source) : c.source;
1733
+ return React.createElement('div', {
1734
+ className: 'frontmcp-markdown prose',
1735
+ dangerouslySetInnerHTML: { __html: html }
1736
+ });
1737
+ }
1738
+ };
1739
+
1740
+ renderers.react = {
1741
+ type: 'react',
1742
+ priority: 30,
1743
+ canHandle: function(c) { return c.type === 'react' || typeof c.source === 'function'; },
1744
+ render: function(c, ctx) {
1745
+ var Component = c.source;
1746
+ var props = Object.assign({
1747
+ output: ctx.output,
1748
+ input: ctx.input,
1749
+ state: ctx.state,
1750
+ data: ctx.output // Alias for convenience
1751
+ }, c.props);
1752
+ return React.createElement(Component, props);
1753
+ }
1754
+ };
1755
+
1756
+ renderers.mdx = {
1757
+ type: 'mdx',
1758
+ priority: 20,
1759
+ canHandle: function(c) {
1760
+ if (c.type === 'mdx') return true;
1761
+ if (typeof c.source !== 'string') return false;
1762
+ var s = c.source;
1763
+ return /<[A-Z][a-zA-Z]*/.test(s) && /^#{1,6}\\s/m.test(s);
1764
+ },
1765
+ render: function(c, ctx) {
1766
+ if (typeof c.compiledContent === 'function') {
1767
+ var MDXContent = c.compiledContent;
1768
+ return React.createElement(MDXContent, {
1769
+ output: ctx.output,
1770
+ input: ctx.input,
1771
+ components: Object.assign({}, ctx.components, c.components)
1772
+ });
1773
+ }
1774
+ return React.createElement('div', { className: 'frontmcp-mdx-fallback' }, [
1775
+ React.createElement('div', {
1776
+ key: 'warn',
1777
+ className: 'bg-yellow-50 border border-yellow-200 rounded p-2 mb-2 text-sm text-yellow-800'
1778
+ }, 'MDX requires pre-compilation. Showing raw content.'),
1779
+ React.createElement('pre', {
1780
+ key: 'pre',
1781
+ className: 'bg-gray-100 p-4 rounded text-sm overflow-auto'
1782
+ }, c.source)
1783
+ ]);
1784
+ }
1785
+ };
1786
+
1787
+ var sortedRenderers = [renderers.react, renderers.mdx, renderers.markdown, renderers.html];
1788
+
1789
+ window.__frontmcp.detectRenderer = function(content) {
1790
+ if (content.type && renderers[content.type]) {
1791
+ return renderers[content.type];
1792
+ }
1793
+ for (var i = 0; i < sortedRenderers.length; i++) {
1794
+ if (sortedRenderers[i].canHandle(content)) {
1795
+ return sortedRenderers[i];
1796
+ }
1797
+ }
1798
+ return renderers.html;
1799
+ };
1800
+
1801
+ window.__frontmcp.renderContent = function(content, context) {
1802
+ var renderer = window.__frontmcp.detectRenderer(content);
1803
+ return renderer.render(content, context);
1804
+ };
1805
+
1806
+ window.__frontmcp.renderers = renderers;
1807
+ })();
1808
+ `;
1809
+ }
1810
+ function buildUIComponentsRuntime() {
1811
+ return `
1812
+ // UI Components (Vendor)
1813
+ (function() {
1814
+ window.Card = function(props) {
1815
+ var children = props.children;
1816
+ var title = props.title;
1817
+ var className = props.className || '';
1818
+ return React.createElement('div', {
1819
+ className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
1820
+ }, [
1821
+ title && React.createElement('div', {
1822
+ key: 'header',
1823
+ className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
1824
+ }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
1825
+ React.createElement('div', { key: 'body', className: 'p-4' }, children)
1826
+ ]);
1827
+ };
1828
+
1829
+ window.Badge = function(props) {
1830
+ var children = props.children;
1831
+ var variant = props.variant || 'default';
1832
+ var variantClasses = {
1833
+ default: 'bg-gray-100 text-gray-800',
1834
+ success: 'bg-green-100 text-green-800',
1835
+ warning: 'bg-yellow-100 text-yellow-800',
1836
+ error: 'bg-red-100 text-red-800',
1837
+ info: 'bg-blue-100 text-blue-800'
1838
+ };
1839
+ return React.createElement('span', {
1840
+ className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
1841
+ }, children);
1842
+ };
1843
+
1844
+ window.Button = function(props) {
1845
+ var children = props.children;
1846
+ var variant = props.variant || 'primary';
1847
+ var onClick = props.onClick;
1848
+ var disabled = props.disabled;
1849
+ var variantClasses = {
1850
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
1851
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
1852
+ outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
1853
+ danger: 'bg-red-600 text-white hover:bg-red-700'
1854
+ };
1855
+ return React.createElement('button', {
1856
+ className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
1857
+ (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
1858
+ (variantClasses[variant] || variantClasses.primary),
1859
+ onClick: onClick,
1860
+ disabled: disabled
1861
+ }, children);
1862
+ };
1863
+
1864
+ // Export to namespace
1865
+ window.frontmcp_ui_namespaceObject = Object.assign({}, window.React || {}, {
1866
+ useToolOutput: window.useToolOutput,
1867
+ useToolInput: window.useToolInput,
1868
+ useMcpBridgeContext: function() { return window.__frontmcp.context; },
1869
+ useCallTool: function() { return function() { return Promise.resolve(null); }; },
1870
+ Card: window.Card,
1871
+ Badge: window.Badge,
1872
+ Button: window.Button
1873
+ });
1874
+ })();
1875
+ `;
1876
+ }
1877
+ function buildUniversalAppRuntime() {
1878
+ return `
1879
+ // Universal App (Vendor)
1880
+ (function() {
1881
+ var LoadingSpinner = function() {
1882
+ return React.createElement('div', {
1883
+ className: 'frontmcp-loading flex items-center justify-center min-h-[200px]'
1884
+ }, React.createElement('div', {
1885
+ className: 'frontmcp-spinner w-6 h-6 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin'
1886
+ }));
1887
+ };
1888
+
1889
+ var ErrorDisplay = function(props) {
1890
+ return React.createElement('div', {
1891
+ className: 'frontmcp-error bg-red-50 border border-red-200 rounded-lg p-4 text-red-800'
1892
+ }, [
1893
+ React.createElement('div', { key: 'title', className: 'font-medium' }, 'Error'),
1894
+ React.createElement('div', { key: 'msg', className: 'text-sm mt-1' }, props.error)
1895
+ ]);
1896
+ };
1897
+
1898
+ var EmptyState = function() {
1899
+ return React.createElement('div', {
1900
+ className: 'frontmcp-empty text-gray-500 text-center py-8'
1901
+ }, 'No content to display');
1902
+ };
1903
+
1904
+ window.__frontmcp.UniversalApp = function(props) {
1905
+ var state = window.useFrontMCPStore();
1906
+
1907
+ if (state.loading) {
1908
+ return props.fallback || React.createElement(LoadingSpinner);
1909
+ }
1910
+
1911
+ if (state.error) {
1912
+ var ErrorComp = props.errorFallback || ErrorDisplay;
1913
+ return React.createElement(ErrorComp, { error: state.error });
1914
+ }
1915
+
1916
+ var content = props.content || state.content;
1917
+
1918
+ if (!content) {
1919
+ return React.createElement(EmptyState);
1920
+ }
1921
+
1922
+ var context = {
1923
+ output: state.output,
1924
+ input: state.input,
1925
+ state: state,
1926
+ components: props.components || {}
1927
+ };
1928
+
1929
+ var rendered = window.__frontmcp.renderContent(content, context);
1930
+ return React.createElement('div', { className: 'frontmcp-content' }, rendered);
1931
+ };
1932
+
1933
+ window.__frontmcp.LoadingSpinner = LoadingSpinner;
1934
+ window.__frontmcp.ErrorDisplay = ErrorDisplay;
1935
+ window.__frontmcp.EmptyState = EmptyState;
1936
+ })();
1937
+ `;
1938
+ }
1939
+ function buildComponentWrapper() {
1940
+ return `
1941
+ // Component Execution (App Chunk)
1942
+ (function() {
1943
+ ${RUNTIME_PLACEHOLDERS.COMPONENT_CODE}
1944
+ })();
1945
+ `;
1946
+ }
1947
+ function buildDataInjectionWrapper() {
1948
+ return `
1949
+ // Data Injection (App Chunk)
1950
+ (function() {
1951
+ ${RUNTIME_PLACEHOLDERS.DATA_INJECTION}
1952
+ })();
1953
+ `;
1954
+ }
1955
+ function buildCustomComponentsWrapper() {
1956
+ return `
1957
+ // Custom Components (App Chunk)
1958
+ (function() {
1959
+ ${RUNTIME_PLACEHOLDERS.CUSTOM_COMPONENTS}
1960
+ })();
1961
+ `;
1962
+ }
1963
+ function buildCdnImports(options) {
1964
+ const parts = [];
1965
+ if (options.cdnType === "esm") {
1966
+ if (options.includeMarkdown) {
1967
+ parts.push(`
1968
+ <script type="module">
1969
+ import ReactMarkdown from '${UNIVERSAL_CDN.esm.reactMarkdown}';
1970
+ window.ReactMarkdown = ReactMarkdown;
1971
+ </script>`);
1972
+ }
1973
+ if (options.includeMdx) {
1974
+ parts.push(`
1975
+ <script type="module">
1976
+ import { MDXProvider } from '${UNIVERSAL_CDN.esm.mdxReact}';
1977
+ window.MDXProvider = MDXProvider;
1978
+ </script>`);
1979
+ }
1980
+ }
1981
+ return parts.join("\n");
1982
+ }
1983
+ function getCachedRuntime(options, config = {}) {
1984
+ const cacheKey = generateCacheKey(options);
1985
+ const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...config };
1986
+ const cached = runtimeCache.get(cacheKey);
1987
+ if (cached) {
1988
+ if (cacheConfig.ttl === 0 || Date.now() - cached.cachedAt < cacheConfig.ttl) {
1989
+ return {
1990
+ vendorScript: cached.script,
1991
+ appTemplate: buildAppTemplate(),
1992
+ cdnImports: cached.cdnImports,
1993
+ vendorSize: cached.size,
1994
+ cached: true,
1995
+ cacheKey
1996
+ };
1997
+ }
1998
+ runtimeCache.delete(cacheKey);
1999
+ }
2000
+ const vendorParts = [buildStoreRuntime(), buildRequireShim()];
2001
+ if (options.cdnType === "umd" || options.includeMarkdown) {
2002
+ vendorParts.push(buildInlineMarkdownParser(options));
2003
+ }
2004
+ vendorParts.push(buildRenderersRuntime(options));
2005
+ vendorParts.push(buildUIComponentsRuntime());
2006
+ vendorParts.push(buildUniversalAppRuntime());
2007
+ let vendorScript = vendorParts.join("\n");
2008
+ if (options.minify) {
2009
+ vendorScript = minifyScript(vendorScript);
2010
+ }
2011
+ const cdnImports = buildCdnImports(options);
2012
+ const entry = {
2013
+ script: vendorScript,
2014
+ cdnImports,
2015
+ size: vendorScript.length,
2016
+ cacheKey,
2017
+ cachedAt: Date.now()
2018
+ };
2019
+ if (runtimeCache.size >= cacheConfig.maxEntries) {
2020
+ const oldestKey = runtimeCache.keys().next().value;
2021
+ if (oldestKey) {
2022
+ runtimeCache.delete(oldestKey);
2023
+ }
2024
+ }
2025
+ runtimeCache.set(cacheKey, entry);
2026
+ return {
2027
+ vendorScript,
2028
+ appTemplate: buildAppTemplate(),
2029
+ cdnImports,
2030
+ vendorSize: vendorScript.length,
2031
+ cached: false,
2032
+ cacheKey
2033
+ };
2034
+ }
2035
+ function buildAppTemplate() {
2036
+ return [buildCustomComponentsWrapper(), buildComponentWrapper(), buildDataInjectionWrapper()].join("\n");
2037
+ }
2038
+ function minifyScript(script) {
2039
+ return script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
2040
+ }
2041
+ function buildAppScript(appTemplate, componentCode, dataInjection, customComponents = "") {
2042
+ 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);
2043
+ }
2044
+ function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
2045
+ const safeJson = (value) => {
2046
+ try {
2047
+ return JSON.stringify(value);
2048
+ } catch {
2049
+ return "null";
2050
+ }
2051
+ };
2052
+ if (hasComponent) {
2053
+ return `
2054
+ window.__frontmcp.setState({
2055
+ toolName: ${safeJson(toolName)},
2056
+ input: ${safeJson(input ?? null)},
2057
+ output: ${safeJson(output ?? null)},
2058
+ structuredContent: ${safeJson(structuredContent ?? null)},
2059
+ content: {
2060
+ type: 'react',
2061
+ source: window.__frontmcp_component
2062
+ },
2063
+ loading: false,
2064
+ error: null
2065
+ });`;
2066
+ }
2067
+ return `
2068
+ window.__frontmcp.setState({
2069
+ toolName: ${safeJson(toolName)},
2070
+ input: ${safeJson(input ?? null)},
2071
+ output: ${safeJson(output ?? null)},
2072
+ structuredContent: ${safeJson(structuredContent ?? null)},
2073
+ content: {
2074
+ type: ${safeJson(contentType)},
2075
+ source: ${safeJson(source)}
2076
+ },
2077
+ loading: false,
2078
+ error: null
2079
+ });`;
2080
+ }
2081
+ function buildComponentCode(transpiledCode) {
2082
+ return `
2083
+ // CommonJS module shim
2084
+ var module = { exports: {} };
2085
+ var exports = module.exports;
2086
+
2087
+ // Execute transpiled component
2088
+ ${transpiledCode}
2089
+
2090
+ // Capture component
2091
+ window.__frontmcp_component = module.exports.default || module.exports;`;
2092
+ }
2093
+
2094
+ // libs/ui/src/bundler/bundler.ts
2095
+ var esbuildTransform = null;
2096
+ async function loadEsbuild() {
2097
+ if (esbuildTransform !== null) {
2098
+ return esbuildTransform;
2099
+ }
2100
+ try {
2101
+ const esbuild = await import("esbuild");
2102
+ esbuildTransform = esbuild.transform;
2103
+ return esbuildTransform;
2104
+ } catch {
2105
+ try {
2106
+ const swc = await import("@swc/core");
2107
+ esbuildTransform = async (source, options) => {
2108
+ const opts = options;
2109
+ const result = await swc.transform(source, {
2110
+ jsc: {
2111
+ parser: {
2112
+ syntax: "typescript",
2113
+ tsx: opts.loader === "tsx" || opts.loader === "jsx"
2114
+ },
2115
+ transform: {
2116
+ react: {
2117
+ runtime: "automatic",
2118
+ development: false
2119
+ }
2120
+ },
2121
+ target: "es2020",
2122
+ minify: opts.minify ? { compress: true, mangle: true } : void 0
2123
+ },
2124
+ module: {
2125
+ type: "commonjs"
2126
+ },
2127
+ sourceMaps: opts.sourcemap ? true : false
2128
+ });
2129
+ return { code: result.code, map: result.map };
2130
+ };
2131
+ return esbuildTransform;
2132
+ } catch {
2133
+ console.warn(
2134
+ "[@frontmcp/ui/bundler] Neither esbuild nor @swc/core available. Install esbuild for best performance: npm install esbuild"
2135
+ );
2136
+ return null;
2137
+ }
2138
+ }
2139
+ }
2140
+ function sanitizeRootId(rootId) {
2141
+ const safeId = rootId.replace(/[^a-zA-Z0-9_-]/g, "");
2142
+ if (safeId !== rootId) {
2143
+ console.warn("[FrontMCP] rootId sanitized:", { original: rootId, sanitized: safeId });
2144
+ }
2145
+ return safeId || "frontmcp-root";
2146
+ }
2147
+ function sanitizeCss(css) {
2148
+ return css.replace(/<\/style>/gi, "\\3c/style\\3e");
2149
+ }
2150
+ var InMemoryBundler = class {
2151
+ cache;
2152
+ options;
2153
+ defaultSecurity;
2154
+ constructor(options = {}) {
2155
+ this.options = {
2156
+ ...DEFAULT_BUNDLER_OPTIONS,
2157
+ ...options,
2158
+ cache: {
2159
+ ...DEFAULT_BUNDLER_OPTIONS.cache,
2160
+ ...options.cache
2161
+ }
2162
+ };
2163
+ this.cache = new BundlerCache({
2164
+ maxSize: this.options.cache.maxSize,
2165
+ ttl: this.options.cache.ttl
2166
+ });
2167
+ this.defaultSecurity = mergePolicy(options.defaultSecurity);
2168
+ }
2169
+ /**
2170
+ * Bundle source code.
2171
+ *
2172
+ * @param options - Bundle options
2173
+ * @returns Bundle result
2174
+ */
2175
+ async bundle(options) {
2176
+ const startTime = performance.now();
2177
+ const opts = this.mergeOptions(options);
2178
+ if (!opts.skipCache && !this.options.cache.disabled) {
2179
+ const cacheKey = options.cacheKey ?? createCacheKey(options.source, opts);
2180
+ const cached = this.cache.get(cacheKey);
2181
+ if (cached) {
2182
+ return {
2183
+ ...cached,
2184
+ cached: true,
2185
+ metrics: {
2186
+ ...cached.metrics,
2187
+ cacheTime: performance.now() - startTime
2188
+ }
2189
+ };
2190
+ }
2191
+ }
2192
+ const security = mergePolicy(options.security ?? this.defaultSecurity);
2193
+ const violations = validateSource(options.source, security);
2194
+ throwOnViolations(violations);
2195
+ const sourceType = opts.sourceType === "auto" ? this.detectSourceType(options.source) : opts.sourceType;
2196
+ const transformStart = performance.now();
2197
+ const transformed = await this.transform(options.source, sourceType, opts);
2198
+ const transformTime = performance.now() - transformStart;
2199
+ const sizeViolation = validateSize(transformed.code.length, security);
2200
+ if (sizeViolation) {
2201
+ throwOnViolations([sizeViolation]);
2202
+ }
2203
+ const hash = hashContent(transformed.code);
2204
+ const result = {
2205
+ code: transformed.code,
2206
+ hash,
2207
+ cached: false,
2208
+ size: transformed.code.length,
2209
+ map: transformed.map,
2210
+ metrics: {
2211
+ transformTime,
2212
+ bundleTime: 0,
2213
+ // No separate bundle step for transform-only
2214
+ totalTime: performance.now() - startTime
2215
+ },
2216
+ sourceType,
2217
+ format: opts.format
2218
+ };
2219
+ if (!this.options.cache.disabled) {
2220
+ const cacheKey = options.cacheKey ?? createCacheKey(options.source, opts);
2221
+ this.cache.set(cacheKey, result);
2222
+ }
2223
+ return result;
2224
+ }
2225
+ /**
2226
+ * Bundle and execute for SSR.
2227
+ *
2228
+ * @param options - SSR bundle options
2229
+ * @returns SSR result with rendered HTML
2230
+ */
2231
+ async bundleSSR(options) {
2232
+ const startTime = performance.now();
2233
+ const bundleResult = await this.bundle({
2234
+ ...options,
2235
+ format: "cjs"
2236
+ // CommonJS for execution
2237
+ });
2238
+ let React;
2239
+ let ReactDOMServer;
2240
+ try {
2241
+ React = await import("react");
2242
+ ReactDOMServer = await import("react-dom/server");
2243
+ } catch {
2244
+ throw new Error("React and react-dom/server are required for SSR. Install them: npm install react react-dom");
2245
+ }
2246
+ const renderStart = performance.now();
2247
+ const Component = await executeDefault(bundleResult.code, {
2248
+ React,
2249
+ security: mergePolicy(options.security ?? this.defaultSecurity)
2250
+ });
2251
+ let html;
2252
+ try {
2253
+ const element = React.createElement(Component, options.context ?? {});
2254
+ html = ReactDOMServer.renderToString(element);
2255
+ } catch (error) {
2256
+ throw new ExecutionError(
2257
+ `SSR rendering failed: ${error instanceof Error ? error.message : String(error)}`,
2258
+ error
2259
+ );
2260
+ }
2261
+ const renderTime = performance.now() - renderStart;
2262
+ let hydrationScript;
2263
+ if (options.includeHydration) {
2264
+ hydrationScript = this.buildHydrationScript(bundleResult.code, options.context);
2265
+ }
2266
+ return {
2267
+ ...bundleResult,
2268
+ html,
2269
+ hydrationScript,
2270
+ metrics: {
2271
+ ...bundleResult.metrics,
2272
+ totalTime: performance.now() - startTime
2273
+ },
2274
+ ssrMetrics: {
2275
+ renderTime
2276
+ }
2277
+ };
2278
+ }
2279
+ /**
2280
+ * Bundle and execute code, returning the exports.
2281
+ *
2282
+ * @param options - Bundle options
2283
+ * @param context - Execution context
2284
+ * @returns Exported value
2285
+ */
2286
+ async bundleAndExecute(options, context) {
2287
+ const result = await this.bundle({
2288
+ ...options,
2289
+ format: "cjs"
2290
+ // CommonJS for execution
2291
+ });
2292
+ let React;
2293
+ try {
2294
+ React = await import("react");
2295
+ } catch {
2296
+ }
2297
+ return executeDefault(result.code, {
2298
+ React,
2299
+ globals: context,
2300
+ security: mergePolicy(options.security ?? this.defaultSecurity)
2301
+ });
2302
+ }
2303
+ /**
2304
+ * Bundle a component to a self-contained static HTML document.
2305
+ *
2306
+ * Creates a complete HTML page with:
2307
+ * - React runtime (CDN or inline based on platform)
2308
+ * - FrontMCP UI hooks and components (always inline)
2309
+ * - Tool data injection (input/output)
2310
+ * - Transpiled component code
2311
+ * - Client-side rendering via createRoot
2312
+ *
2313
+ * @param options - Static HTML options
2314
+ * @returns Static HTML result with complete document
2315
+ *
2316
+ * @example
2317
+ * ```typescript
2318
+ * const result = await bundler.bundleToStaticHTML({
2319
+ * source: `
2320
+ * import { Card, useToolOutput } from '@frontmcp/ui/react';
2321
+ * export default function Weather() {
2322
+ * const output = useToolOutput();
2323
+ * return <Card title="Weather">{output?.temperature}°F</Card>;
2324
+ * }
2325
+ * `,
2326
+ * toolName: 'get_weather',
2327
+ * output: { temperature: 72 },
2328
+ * });
2329
+ *
2330
+ * // result.html contains the complete HTML document
2331
+ * ```
2332
+ */
2333
+ async bundleToStaticHTML(options) {
2334
+ const startTime = performance.now();
2335
+ const opts = this.mergeStaticHTMLOptions(options);
2336
+ const platform = opts.targetPlatform === "auto" ? "generic" : opts.targetPlatform;
2337
+ const cdnType = getCdnTypeForPlatform(platform);
2338
+ if (opts.universal) {
2339
+ return this.bundleToStaticHTMLUniversal(options, opts, platform, cdnType, startTime);
2340
+ }
2341
+ const bundleResult = await this.bundle({
2342
+ source: options.source,
2343
+ sourceType: opts.sourceType,
2344
+ format: "cjs",
2345
+ minify: opts.minify,
2346
+ sourceMaps: false,
2347
+ externals: ["react", "react-dom", "react/jsx-runtime", "@frontmcp/ui", "@frontmcp/ui/react"],
2348
+ security: opts.security,
2349
+ skipCache: opts.skipCache
2350
+ });
2351
+ const head = this.buildStaticHTMLHead({ externals: opts.externals, customCss: opts.customCss });
2352
+ const reactRuntime = this.buildReactRuntimeScripts(opts.externals, platform, cdnType);
2353
+ const frontmcpRuntime = this.buildFrontMCPRuntime();
2354
+ const dataScript = this.buildDataInjectionScript(opts.toolName, opts.input, opts.output, opts.structuredContent);
2355
+ const componentScript = this.buildComponentRenderScript(bundleResult.code, opts.rootId, cdnType);
2356
+ const html = this.assembleStaticHTML({
2357
+ title: opts.title || `${opts.toolName} - Widget`,
2358
+ head,
2359
+ reactRuntime,
2360
+ frontmcpRuntime,
2361
+ dataScript,
2362
+ componentScript,
2363
+ rootId: opts.rootId,
2364
+ cdnType
2365
+ });
2366
+ const hash = hashContent(html);
2367
+ return {
2368
+ html,
2369
+ componentCode: bundleResult.code,
2370
+ metrics: {
2371
+ ...bundleResult.metrics,
2372
+ totalTime: performance.now() - startTime
2373
+ },
2374
+ hash,
2375
+ size: html.length,
2376
+ cached: bundleResult.cached,
2377
+ sourceType: bundleResult.sourceType,
2378
+ targetPlatform: platform
2379
+ };
2380
+ }
2381
+ /**
2382
+ * Bundle to static HTML with universal rendering mode.
2383
+ * Uses the universal renderer that can handle multiple content types.
2384
+ *
2385
+ * Optimization: Uses cached runtime (vendor chunk) to avoid rebuilding
2386
+ * static code on every request. Only the user's component is transpiled.
2387
+ */
2388
+ async bundleToStaticHTMLUniversal(options, opts, platform, cdnType, startTime) {
2389
+ let contentType;
2390
+ const rawContentType = options.contentType ?? "auto";
2391
+ if (rawContentType === "auto") {
2392
+ contentType = detectContentType(options.source);
2393
+ } else {
2394
+ contentType = rawContentType;
2395
+ }
2396
+ let transpiledCode = null;
2397
+ let transformTime = 0;
2398
+ if (contentType === "react") {
2399
+ const bundleResult = await this.bundle({
2400
+ source: options.source,
2401
+ sourceType: opts.sourceType,
2402
+ format: "cjs",
2403
+ minify: opts.minify,
2404
+ sourceMaps: false,
2405
+ externals: ["react", "react-dom", "react/jsx-runtime", "@frontmcp/ui", "@frontmcp/ui/react"],
2406
+ security: opts.security,
2407
+ skipCache: opts.skipCache
2408
+ });
2409
+ transpiledCode = bundleResult.code;
2410
+ transformTime = bundleResult.metrics.transformTime;
2411
+ }
2412
+ const cachedRuntime = getCachedRuntime({
2413
+ cdnType,
2414
+ includeMarkdown: opts.includeMarkdown || contentType === "markdown",
2415
+ includeMdx: opts.includeMdx || contentType === "mdx",
2416
+ minify: opts.minify
2417
+ });
2418
+ const componentCodeStr = transpiledCode ? buildComponentCode(transpiledCode) : "";
2419
+ const dataInjectionStr = buildDataInjectionCode(
2420
+ opts.toolName,
2421
+ opts.input,
2422
+ opts.output,
2423
+ opts.structuredContent,
2424
+ contentType,
2425
+ transpiledCode ? null : options.source,
2426
+ // Pass source only if not a component
2427
+ transpiledCode !== null
2428
+ );
2429
+ const appScript = buildAppScript(
2430
+ cachedRuntime.appTemplate,
2431
+ componentCodeStr,
2432
+ dataInjectionStr,
2433
+ opts.customComponents ?? ""
2434
+ );
2435
+ const head = this.buildStaticHTMLHead({ externals: opts.externals, customCss: opts.customCss });
2436
+ const reactRuntime = this.buildReactRuntimeScripts(opts.externals, platform, cdnType);
2437
+ const renderScript = this.buildUniversalRenderScript(opts.rootId, cdnType);
2438
+ const html = this.assembleUniversalStaticHTMLCached({
2439
+ title: opts.title || `${opts.toolName} - Widget`,
2440
+ head,
2441
+ reactRuntime,
2442
+ cdnImports: cachedRuntime.cdnImports,
2443
+ vendorScript: cachedRuntime.vendorScript,
2444
+ appScript,
2445
+ renderScript,
2446
+ rootId: opts.rootId,
2447
+ cdnType
2448
+ });
2449
+ const hash = hashContent(html);
2450
+ return {
2451
+ html,
2452
+ componentCode: transpiledCode ?? appScript,
2453
+ metrics: {
2454
+ transformTime,
2455
+ bundleTime: 0,
2456
+ totalTime: performance.now() - startTime,
2457
+ cacheTime: cachedRuntime.cached ? 0 : void 0
2458
+ },
2459
+ hash,
2460
+ size: html.length,
2461
+ cached: cachedRuntime.cached,
2462
+ sourceType: opts.sourceType === "auto" ? this.detectSourceType(options.source) : opts.sourceType,
2463
+ targetPlatform: platform,
2464
+ universal: true,
2465
+ contentType
2466
+ };
2467
+ }
2468
+ /**
2469
+ * Assemble the complete universal static HTML document using cached runtime.
2470
+ *
2471
+ * For ESM mode (OpenAI), scripts must wait for React to load asynchronously.
2472
+ * For UMD mode (Claude), scripts can execute synchronously.
2473
+ */
2474
+ assembleUniversalStaticHTMLCached(parts) {
2475
+ if (parts.cdnType === "umd") {
2476
+ return `<!DOCTYPE html>
2477
+ <html lang="en">
2478
+ <head>
2479
+ <title>${(0, import_utils.escapeHtml)(parts.title)}</title>
2480
+ ${parts.head}
2481
+ ${parts.reactRuntime}
2482
+ ${parts.cdnImports}
2483
+ <!-- Vendor Runtime (Cached) -->
2484
+ <script>
2485
+ ${parts.vendorScript}
2486
+ </script>
2487
+ <!-- App Script (User Component) -->
2488
+ <script>
2489
+ ${parts.appScript}
2490
+ </script>
2491
+ </head>
2492
+ <body>
2493
+ <div id="${parts.rootId}" class="frontmcp-loading">
2494
+ <div class="frontmcp-spinner"></div>
2495
+ </div>
2496
+ ${parts.renderScript}
2497
+ </body>
2498
+ </html>`;
2499
+ } else {
2500
+ return `<!DOCTYPE html>
2501
+ <html lang="en">
2502
+ <head>
2503
+ <title>${(0, import_utils.escapeHtml)(parts.title)}</title>
2504
+ ${parts.head}
2505
+ ${parts.reactRuntime}
2506
+ ${parts.cdnImports}
2507
+ </head>
2508
+ <body>
2509
+ <div id="${parts.rootId}" class="frontmcp-loading">
2510
+ <div class="frontmcp-spinner"></div>
2511
+ </div>
2512
+ <!-- Scripts wait for React to load (ESM is async) -->
2513
+ <script type="module">
2514
+ // Wait for React to be ready
2515
+ function initFrontMCP() {
2516
+ // Vendor Runtime (Cached)
2517
+ ${parts.vendorScript}
2518
+
2519
+ // App Script (User Component)
2520
+ ${parts.appScript}
2521
+
2522
+ // Render the app
2523
+ var container = document.getElementById('${parts.rootId}');
2524
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2525
+ var root = window.ReactDOM.createRoot(container);
2526
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2527
+ }
2528
+ }
2529
+
2530
+ if (window.__reactReady) {
2531
+ initFrontMCP();
2532
+ } else {
2533
+ window.addEventListener('react:ready', initFrontMCP);
2534
+ }
2535
+ </script>
2536
+ </body>
2537
+ </html>`;
2538
+ }
2539
+ }
2540
+ /**
2541
+ * Build the component script for transpiled React/MDX content.
2542
+ * Wraps CommonJS code with module/exports shim to capture the component.
2543
+ */
2544
+ buildUniversalComponentScript(transpiledCode, cdnType) {
2545
+ const wrappedCode = `
2546
+ // CommonJS module shim
2547
+ var module = { exports: {} };
2548
+ var exports = module.exports;
2549
+
2550
+ // Execute transpiled component code (CommonJS format)
2551
+ ${transpiledCode}
2552
+
2553
+ // Capture the component export
2554
+ window.__frontmcp_component = module.exports.default || module.exports;
2555
+ `;
2556
+ if (cdnType === "umd") {
2557
+ return `
2558
+ <!-- Universal Component Script (transpiled) -->
2559
+ <script>
2560
+ (function() {
2561
+ ${wrappedCode}
2562
+ })();
2563
+ </script>`;
2564
+ } else {
2565
+ return `
2566
+ <!-- Universal Component Script (transpiled, ESM) -->
2567
+ <script type="module">
2568
+ function loadComponent() {
2569
+ ${wrappedCode}
2570
+ }
2571
+
2572
+ if (window.__reactReady) {
2573
+ loadComponent();
2574
+ } else {
2575
+ window.addEventListener('react:ready', loadComponent);
2576
+ }
2577
+ </script>`;
2578
+ }
2579
+ }
2580
+ /**
2581
+ * Build the universal runtime script section.
2582
+ */
2583
+ buildUniversalRuntimeScript(runtimeScript) {
2584
+ return `
2585
+ <!-- Universal Runtime -->
2586
+ <script>
2587
+ ${runtimeScript}
2588
+ </script>`;
2589
+ }
2590
+ /**
2591
+ * Build data injection script for universal mode.
2592
+ */
2593
+ buildUniversalDataScript(toolName, input, output, structuredContent, contentType, source, hasTranspiledComponent = false) {
2594
+ const safeJson = (value) => {
2595
+ try {
2596
+ return JSON.stringify(value);
2597
+ } catch {
2598
+ return "null";
2599
+ }
2600
+ };
2601
+ if (hasTranspiledComponent) {
2602
+ return `
2603
+ <!-- Universal Data Injection (React Component) -->
2604
+ <script>
2605
+ window.__frontmcp.setState({
2606
+ toolName: ${safeJson(toolName)},
2607
+ input: ${safeJson(input ?? null)},
2608
+ output: ${safeJson(output ?? null)},
2609
+ structuredContent: ${safeJson(structuredContent ?? null)},
2610
+ content: {
2611
+ type: 'react',
2612
+ source: window.__frontmcp_component
2613
+ },
2614
+ loading: false,
2615
+ error: null
2616
+ });
2617
+ </script>`;
2618
+ }
2619
+ const escapedSource = JSON.stringify(source);
2620
+ return `
2621
+ <!-- Universal Data Injection -->
2622
+ <script>
2623
+ window.__frontmcp.setState({
2624
+ toolName: ${safeJson(toolName)},
2625
+ input: ${safeJson(input ?? null)},
2626
+ output: ${safeJson(output ?? null)},
2627
+ structuredContent: ${safeJson(structuredContent ?? null)},
2628
+ content: {
2629
+ type: ${safeJson(contentType)},
2630
+ source: ${escapedSource}
2631
+ },
2632
+ loading: false,
2633
+ error: null
2634
+ });
2635
+ </script>`;
2636
+ }
2637
+ /**
2638
+ * Build the universal render script.
2639
+ */
2640
+ buildUniversalRenderScript(rootId, cdnType) {
2641
+ if (cdnType === "umd") {
2642
+ return `
2643
+ <!-- Universal Render Script (UMD - synchronous) -->
2644
+ <script>
2645
+ (function() {
2646
+ var container = document.getElementById('${rootId}');
2647
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2648
+ var root = window.ReactDOM.createRoot(container);
2649
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2650
+ } else if (container && window.ReactDOM && window.ReactDOM.render && window.__frontmcp.UniversalApp) {
2651
+ window.ReactDOM.render(
2652
+ React.createElement(window.__frontmcp.UniversalApp),
2653
+ container
2654
+ );
2655
+ }
2656
+ })();
2657
+ </script>`;
2658
+ } else {
2659
+ return `
2660
+ <!-- Universal Render Script (ESM - waits for React) -->
2661
+ <script type="module">
2662
+ function renderUniversalApp() {
2663
+ var container = document.getElementById('${rootId}');
2664
+ if (container && window.ReactDOM && window.ReactDOM.createRoot && window.__frontmcp.UniversalApp) {
2665
+ var root = window.ReactDOM.createRoot(container);
2666
+ root.render(React.createElement(window.__frontmcp.UniversalApp));
2667
+ }
2668
+ }
2669
+
2670
+ if (window.__reactReady) {
2671
+ renderUniversalApp();
2672
+ } else {
2673
+ window.addEventListener('react:ready', renderUniversalApp);
2674
+ }
2675
+ </script>`;
2676
+ }
2677
+ }
2678
+ /**
2679
+ * Assemble the complete universal static HTML document.
2680
+ */
2681
+ assembleUniversalStaticHTML(parts) {
2682
+ return `<!DOCTYPE html>
2683
+ <html lang="en">
2684
+ <head>
2685
+ <title>${(0, import_utils.escapeHtml)(parts.title)}</title>
2686
+ ${parts.head}
2687
+ ${parts.reactRuntime}
2688
+ ${parts.frontmcpRuntime ?? ""}
2689
+ ${parts.cdnImports}
2690
+ ${parts.universalRuntimeScript}
2691
+ ${parts.componentScript ?? ""}
2692
+ ${parts.dataScript}
2693
+ </head>
2694
+ <body>
2695
+ <div id="${parts.rootId}" class="frontmcp-loading">
2696
+ <div class="frontmcp-spinner"></div>
2697
+ </div>
2698
+ ${parts.renderScript}
2699
+ </body>
2700
+ </html>`;
2701
+ }
2702
+ /**
2703
+ * Get cache statistics.
2704
+ */
2705
+ getCacheStats() {
2706
+ return this.cache.getStats();
2707
+ }
2708
+ /**
2709
+ * Clear the cache.
2710
+ */
2711
+ clearCache() {
2712
+ this.cache.clear();
2713
+ }
2714
+ /**
2715
+ * Clean up expired cache entries.
2716
+ */
2717
+ cleanupCache() {
2718
+ return this.cache.cleanup();
2719
+ }
2720
+ /**
2721
+ * Transform source code using esbuild/SWC.
2722
+ */
2723
+ async transform(source, sourceType, options) {
2724
+ const transform = await loadEsbuild();
2725
+ if (!transform) {
2726
+ throw new Error("No bundler available. Install esbuild or @swc/core: npm install esbuild");
2727
+ }
2728
+ const loader = this.getLoader(sourceType);
2729
+ const esbuildOptions = {
2730
+ loader,
2731
+ minify: options.minify,
2732
+ sourcemap: options.sourceMaps,
2733
+ target: options.target,
2734
+ format: options.format === "cjs" ? "cjs" : options.format === "esm" ? "esm" : "iife",
2735
+ jsx: "automatic",
2736
+ jsxImportSource: options.jsx.importSource
2737
+ };
2738
+ try {
2739
+ const result = await transform(source, esbuildOptions);
2740
+ return {
2741
+ code: result.code,
2742
+ map: result.map
2743
+ };
2744
+ } catch (error) {
2745
+ throw new Error(`Transform failed: ${error instanceof Error ? error.message : String(error)}`);
2746
+ }
2747
+ }
2748
+ /**
2749
+ * Get esbuild loader for source type.
2750
+ */
2751
+ getLoader(sourceType) {
2752
+ switch (sourceType) {
2753
+ case "jsx":
2754
+ return "jsx";
2755
+ case "tsx":
2756
+ return "tsx";
2757
+ case "mdx":
2758
+ return "tsx";
2759
+ // MDX compiles to JSX/TSX
2760
+ case "html":
2761
+ return "text";
2762
+ default:
2763
+ return "tsx";
2764
+ }
2765
+ }
2766
+ /**
2767
+ * Detect source type from content.
2768
+ */
2769
+ detectSourceType(source) {
2770
+ 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);
2771
+ const hasJSX = /<[A-Z][a-zA-Z]*/.test(source) || // Component tags
2772
+ /<[a-z]+\s/.test(source) || // HTML tags with attributes
2773
+ /<[a-z]+>/.test(source) || // Self-closing HTML tags
2774
+ /<\/[a-z]+>/.test(source);
2775
+ const hasMDX = /^#\s+/.test(source) || // Markdown heading
2776
+ /^-\s+/.test(source) || // Markdown list
2777
+ /\*\*\w+\*\*/.test(source) || // Bold
2778
+ /```\w*\n/.test(source);
2779
+ if (hasMDX && hasJSX) {
2780
+ return "mdx";
2781
+ }
2782
+ if (hasTypeScript && hasJSX) {
2783
+ return "tsx";
2784
+ }
2785
+ if (hasJSX) {
2786
+ return "jsx";
2787
+ }
2788
+ if (hasTypeScript) {
2789
+ return "tsx";
2790
+ }
2791
+ return "jsx";
2792
+ }
2793
+ /**
2794
+ * Merge bundle options with defaults.
2795
+ */
2796
+ mergeOptions(options) {
2797
+ return {
2798
+ sourceType: options.sourceType ?? DEFAULT_BUNDLE_OPTIONS.sourceType,
2799
+ format: options.format ?? DEFAULT_BUNDLE_OPTIONS.format,
2800
+ minify: options.minify ?? DEFAULT_BUNDLE_OPTIONS.minify,
2801
+ sourceMaps: options.sourceMaps ?? DEFAULT_BUNDLE_OPTIONS.sourceMaps,
2802
+ externals: options.externals ?? DEFAULT_BUNDLE_OPTIONS.externals,
2803
+ jsx: {
2804
+ ...DEFAULT_BUNDLE_OPTIONS.jsx,
2805
+ ...options.jsx
2806
+ },
2807
+ target: options.target ?? DEFAULT_BUNDLE_OPTIONS.target,
2808
+ globalName: options.globalName ?? DEFAULT_BUNDLE_OPTIONS.globalName,
2809
+ skipCache: options.skipCache ?? DEFAULT_BUNDLE_OPTIONS.skipCache
2810
+ };
2811
+ }
2812
+ /**
2813
+ * Build hydration script for client-side React.
2814
+ */
2815
+ buildHydrationScript(bundledCode, context) {
2816
+ const contextJson = context ? JSON.stringify(context) : "{}";
2817
+ return `
2818
+ (function() {
2819
+ var context = ${contextJson};
2820
+ var exports = {};
2821
+ var module = { exports: exports };
2822
+
2823
+ // Execute bundled code
2824
+ (function(exports, module) {
2825
+ ${bundledCode}
2826
+ })(exports, module);
2827
+
2828
+ // Get component
2829
+ var Component = module.exports.default || module.exports;
2830
+
2831
+ // Hydrate
2832
+ if (typeof ReactDOM !== 'undefined' && ReactDOM.hydrateRoot) {
2833
+ var container = document.getElementById('root') || document.body.firstElementChild;
2834
+ if (container) {
2835
+ ReactDOM.hydrateRoot(container, React.createElement(Component, context));
2836
+ }
2837
+ }
2838
+ })();
2839
+ `.trim();
2840
+ }
2841
+ // ============================================
2842
+ // Static HTML Helper Methods
2843
+ // ============================================
2844
+ /**
2845
+ * Merge static HTML options with defaults.
2846
+ */
2847
+ mergeStaticHTMLOptions(options) {
2848
+ return {
2849
+ sourceType: options.sourceType ?? DEFAULT_STATIC_HTML_OPTIONS.sourceType,
2850
+ targetPlatform: options.targetPlatform ?? DEFAULT_STATIC_HTML_OPTIONS.targetPlatform,
2851
+ minify: options.minify ?? DEFAULT_STATIC_HTML_OPTIONS.minify,
2852
+ skipCache: options.skipCache ?? DEFAULT_STATIC_HTML_OPTIONS.skipCache,
2853
+ rootId: sanitizeRootId(options.rootId ?? DEFAULT_STATIC_HTML_OPTIONS.rootId),
2854
+ widgetAccessible: options.widgetAccessible ?? DEFAULT_STATIC_HTML_OPTIONS.widgetAccessible,
2855
+ externals: {
2856
+ ...DEFAULT_STATIC_HTML_OPTIONS.externals,
2857
+ ...options.externals
2858
+ },
2859
+ // Universal mode options
2860
+ universal: options.universal ?? DEFAULT_STATIC_HTML_OPTIONS.universal,
2861
+ contentType: options.contentType ?? DEFAULT_STATIC_HTML_OPTIONS.contentType,
2862
+ includeMarkdown: options.includeMarkdown ?? DEFAULT_STATIC_HTML_OPTIONS.includeMarkdown,
2863
+ includeMdx: options.includeMdx ?? DEFAULT_STATIC_HTML_OPTIONS.includeMdx,
2864
+ // Pass-through options
2865
+ toolName: options.toolName,
2866
+ input: options.input,
2867
+ output: options.output,
2868
+ structuredContent: options.structuredContent,
2869
+ title: options.title,
2870
+ security: options.security,
2871
+ customCss: options.customCss,
2872
+ customComponents: options.customComponents
2873
+ };
2874
+ }
2875
+ /**
2876
+ * Build the <head> section for static HTML.
2877
+ */
2878
+ buildStaticHTMLHead(opts) {
2879
+ const parts = [];
2880
+ parts.push(`<meta charset="UTF-8">`);
2881
+ parts.push(`<meta name="viewport" content="width=device-width, initial-scale=1.0">`);
2882
+ for (const url of STATIC_HTML_CDN.fonts.preconnect) {
2883
+ parts.push(`<link rel="preconnect" href="${url}" crossorigin>`);
2884
+ }
2885
+ parts.push(`<link rel="stylesheet" href="${STATIC_HTML_CDN.fonts.inter}">`);
2886
+ const tailwindConfig = opts.externals.tailwind ?? "cdn";
2887
+ if (tailwindConfig === "cdn") {
2888
+ parts.push(`<link rel="stylesheet" href="${STATIC_HTML_CDN.tailwind}">`);
2889
+ } else if (tailwindConfig !== "inline" && tailwindConfig) {
2890
+ parts.push(`<link rel="stylesheet" href="${tailwindConfig}">`);
2891
+ }
2892
+ parts.push(`<style>
2893
+ body { margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
2894
+ .frontmcp-loading { display: flex; align-items: center; justify-content: center; min-height: 200px; }
2895
+ .frontmcp-spinner { width: 24px; height: 24px; border: 2px solid #e5e7eb; border-top-color: #3b82f6; border-radius: 50%; animation: spin 1s linear infinite; }
2896
+ @keyframes spin { to { transform: rotate(360deg); } }
2897
+ </style>`);
2898
+ if (opts.customCss) {
2899
+ parts.push(`<style>
2900
+ ${sanitizeCss(opts.customCss)}
2901
+ </style>`);
2902
+ }
2903
+ return parts.join("\n ");
2904
+ }
2905
+ /**
2906
+ * Build React runtime scripts for static HTML.
2907
+ */
2908
+ buildReactRuntimeScripts(externals, platform, cdnType) {
2909
+ const reactConfig = externals.react ?? "cdn";
2910
+ const reactDomConfig = externals.reactDom ?? "cdn";
2911
+ if (cdnType === "umd") {
2912
+ const reactUrl = reactConfig === "cdn" ? STATIC_HTML_CDN.umd.react : reactConfig;
2913
+ const reactDomUrl = reactDomConfig === "cdn" ? STATIC_HTML_CDN.umd.reactDom : reactDomConfig;
2914
+ return `
2915
+ <!-- React Runtime (UMD from cdnjs - Claude compatible) -->
2916
+ <script src="${reactUrl}"></script>
2917
+ <script src="${reactDomUrl}"></script>
2918
+ <script>
2919
+ // Webpack/esbuild polyfills for transpiled code (UMD globals)
2920
+ window.external_react_namespaceObject = window.React;
2921
+ window.jsx_runtime_namespaceObject = {
2922
+ jsx: function(type, props, key) {
2923
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2924
+ return React.createElement(type, props);
2925
+ },
2926
+ jsxs: function(type, props, key) {
2927
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2928
+ return React.createElement(type, props);
2929
+ },
2930
+ Fragment: React.Fragment
2931
+ };
2932
+ window.__reactReady = true;
2933
+ </script>`;
2934
+ } else {
2935
+ const reactUrl = reactConfig === "cdn" ? STATIC_HTML_CDN.esm.react : reactConfig;
2936
+ const reactDomUrl = reactDomConfig === "cdn" ? STATIC_HTML_CDN.esm.reactDom : reactDomConfig;
2937
+ return `
2938
+ <!-- React Runtime (ES modules from esm.sh) -->
2939
+ <script type="module">
2940
+ import React from '${reactUrl}';
2941
+ import { createRoot } from '${reactDomUrl}';
2942
+
2943
+ // Make React available globally
2944
+ window.React = React;
2945
+ window.ReactDOM = { createRoot };
2946
+
2947
+ // Webpack/esbuild polyfills for transpiled code
2948
+ window.external_react_namespaceObject = React;
2949
+ window.jsx_runtime_namespaceObject = {
2950
+ jsx: function(type, props, key) {
2951
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2952
+ return React.createElement(type, props);
2953
+ },
2954
+ jsxs: function(type, props, key) {
2955
+ if (key !== undefined) props = Object.assign({}, props, { key: key });
2956
+ return React.createElement(type, props);
2957
+ },
2958
+ Fragment: React.Fragment
2959
+ };
2960
+
2961
+ // Signal React is ready
2962
+ window.__reactReady = true;
2963
+ window.dispatchEvent(new CustomEvent('react:ready'));
2964
+ </script>`;
2965
+ }
2966
+ }
2967
+ /**
2968
+ * Build FrontMCP runtime (hooks and UI components).
2969
+ * Always inlined for reliability across platforms.
2970
+ */
2971
+ buildFrontMCPRuntime() {
2972
+ return `
2973
+ <!-- FrontMCP Runtime (always inline) -->
2974
+ <script>
2975
+ // Custom require() shim for browser - maps module names to globals
2976
+ // This allows esbuild-transpiled code to work in browsers
2977
+ window.__moduleCache = {};
2978
+ window.require = function(moduleName) {
2979
+ // Check cache first
2980
+ if (window.__moduleCache[moduleName]) {
2981
+ return window.__moduleCache[moduleName];
2982
+ }
2983
+
2984
+ // Map module names to browser globals
2985
+ var moduleMap = {
2986
+ 'react': function() { return window.React; },
2987
+ 'react-dom': function() { return window.ReactDOM; },
2988
+ 'react-dom/client': function() { return window.ReactDOM; },
2989
+ 'react/jsx-runtime': function() { return window.jsx_runtime_namespaceObject; },
2990
+ 'react/jsx-dev-runtime': function() { return window.jsx_runtime_namespaceObject; },
2991
+ '@frontmcp/ui': function() { return window.react_namespaceObject; },
2992
+ '@frontmcp/ui/react': function() { return window.react_namespaceObject; },
2993
+ };
2994
+
2995
+ var resolver = moduleMap[moduleName];
2996
+ if (resolver) {
2997
+ var mod = resolver();
2998
+ window.__moduleCache[moduleName] = mod;
2999
+ return mod;
3000
+ }
3001
+
3002
+ console.warn('[FrontMCP] Unknown module requested:', moduleName);
3003
+ return {};
3004
+ };
3005
+
3006
+ // Async require for dynamic imports (returns Promise)
3007
+ window.requireAsync = function(moduleName) {
3008
+ return new Promise(function(resolve, reject) {
3009
+ // If module is already loaded, resolve immediately
3010
+ var mod = window.require(moduleName);
3011
+ if (mod && Object.keys(mod).length > 0) {
3012
+ resolve(mod);
3013
+ return;
3014
+ }
3015
+
3016
+ // For now, we don't support dynamic CDN loading
3017
+ // All required modules should be pre-loaded
3018
+ console.warn('[FrontMCP] Async module not available:', moduleName);
3019
+ resolve({});
3020
+ });
3021
+ };
3022
+
3023
+ // FrontMCP Hook implementations
3024
+ window.__frontmcp = {
3025
+ // Context for MCP bridge
3026
+ context: {
3027
+ toolName: null,
3028
+ toolInput: null,
3029
+ toolOutput: null,
3030
+ structuredContent: null,
3031
+ callTool: null,
3032
+ },
3033
+
3034
+ // Set context from data injection
3035
+ setContext: function(ctx) {
3036
+ Object.assign(this.context, ctx);
3037
+ },
3038
+ };
3039
+
3040
+ // Hook: useToolOutput - returns the tool output data
3041
+ window.useToolOutput = function() {
3042
+ return window.__frontmcp.context.toolOutput;
3043
+ };
3044
+
3045
+ // Hook: useToolInput - returns the tool input arguments
3046
+ window.useToolInput = function() {
3047
+ return window.__frontmcp.context.toolInput;
3048
+ };
3049
+
3050
+ // Hook: useMcpBridgeContext - returns full bridge context
3051
+ window.useMcpBridgeContext = function() {
3052
+ return window.__frontmcp.context;
3053
+ };
3054
+
3055
+ // Hook: useCallTool - returns function to call other tools
3056
+ window.useCallTool = function() {
3057
+ return function(name, args) {
3058
+ if (window.__frontmcp.context.callTool) {
3059
+ return window.__frontmcp.context.callTool(name, args);
3060
+ }
3061
+ console.warn('[FrontMCP] callTool not available - widget may not have tool access');
3062
+ return Promise.resolve(null);
3063
+ };
3064
+ };
3065
+
3066
+ // UI Components (simplified inline versions)
3067
+ window.Card = function(props) {
3068
+ var children = props.children;
3069
+ var title = props.title;
3070
+ var className = props.className || '';
3071
+ return React.createElement('div', {
3072
+ className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
3073
+ }, [
3074
+ title && React.createElement('div', {
3075
+ key: 'header',
3076
+ className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
3077
+ }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
3078
+ React.createElement('div', { key: 'body', className: 'p-4' }, children)
3079
+ ]);
3080
+ };
3081
+
3082
+ window.Badge = function(props) {
3083
+ var children = props.children;
3084
+ var variant = props.variant || 'default';
3085
+ var variantClasses = {
3086
+ default: 'bg-gray-100 text-gray-800',
3087
+ success: 'bg-green-100 text-green-800',
3088
+ warning: 'bg-yellow-100 text-yellow-800',
3089
+ error: 'bg-red-100 text-red-800',
3090
+ info: 'bg-blue-100 text-blue-800',
3091
+ };
3092
+ return React.createElement('span', {
3093
+ className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
3094
+ }, children);
3095
+ };
3096
+
3097
+ window.Button = function(props) {
3098
+ var children = props.children;
3099
+ var variant = props.variant || 'primary';
3100
+ var onClick = props.onClick;
3101
+ var disabled = props.disabled;
3102
+ var variantClasses = {
3103
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
3104
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
3105
+ outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
3106
+ danger: 'bg-red-600 text-white hover:bg-red-700',
3107
+ };
3108
+ return React.createElement('button', {
3109
+ className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
3110
+ (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
3111
+ (variantClasses[variant] || variantClasses.primary),
3112
+ onClick: onClick,
3113
+ disabled: disabled,
3114
+ }, children);
3115
+ };
3116
+
3117
+ // Make hooks available on react_namespaceObject for bundled imports
3118
+ window.react_namespaceObject = Object.assign({}, window.React || {}, {
3119
+ useToolOutput: window.useToolOutput,
3120
+ useToolInput: window.useToolInput,
3121
+ useMcpBridgeContext: window.useMcpBridgeContext,
3122
+ useCallTool: window.useCallTool,
3123
+ Card: window.Card,
3124
+ Badge: window.Badge,
3125
+ Button: window.Button,
3126
+ });
3127
+ </script>`;
3128
+ }
3129
+ /**
3130
+ * Build data injection script for tool input/output.
3131
+ */
3132
+ buildDataInjectionScript(toolName, input, output, structuredContent) {
3133
+ const safeJson = (value) => {
3134
+ try {
3135
+ return JSON.stringify(value);
3136
+ } catch {
3137
+ return "null";
3138
+ }
3139
+ };
3140
+ return `
3141
+ <!-- Tool Data Injection -->
3142
+ <script>
3143
+ window.__mcpToolName = ${safeJson(toolName)};
3144
+ window.__mcpToolInput = ${safeJson(input ?? null)};
3145
+ window.__mcpToolOutput = ${safeJson(output ?? null)};
3146
+ window.__mcpStructuredContent = ${safeJson(structuredContent ?? null)};
3147
+
3148
+ // Initialize FrontMCP context
3149
+ window.__frontmcp.setContext({
3150
+ toolName: window.__mcpToolName,
3151
+ toolInput: window.__mcpToolInput,
3152
+ toolOutput: window.__mcpToolOutput,
3153
+ structuredContent: window.__mcpStructuredContent,
3154
+ });
3155
+ </script>`;
3156
+ }
3157
+ /**
3158
+ * Build component render script.
3159
+ * Wraps CommonJS code with module/exports shim to capture the component.
3160
+ */
3161
+ buildComponentRenderScript(componentCode, rootId, cdnType) {
3162
+ const wrappedCode = `
3163
+ // CommonJS module shim
3164
+ var module = { exports: {} };
3165
+ var exports = module.exports;
3166
+
3167
+ // Execute transpiled component code (CommonJS format)
3168
+ ${componentCode}
3169
+
3170
+ // Capture the component export
3171
+ window.__frontmcp_component = module.exports;
3172
+ `;
3173
+ if (cdnType === "umd") {
3174
+ return `
3175
+ <!-- Component Render Script (UMD - synchronous) -->
3176
+ <script>
3177
+ (function() {
3178
+ ${wrappedCode}
3179
+
3180
+ // Get the component
3181
+ var Component = window.__frontmcp_component.default || window.__frontmcp_component;
3182
+
3183
+ // Render the component
3184
+ var container = document.getElementById('${rootId}');
3185
+ if (container && window.ReactDOM && window.ReactDOM.createRoot) {
3186
+ var root = window.ReactDOM.createRoot(container);
3187
+ root.render(React.createElement(Component, {
3188
+ output: window.__mcpToolOutput,
3189
+ input: window.__mcpToolInput,
3190
+ }));
3191
+ } else if (container && window.ReactDOM && window.ReactDOM.render) {
3192
+ // Fallback for React 17
3193
+ window.ReactDOM.render(
3194
+ React.createElement(Component, {
3195
+ output: window.__mcpToolOutput,
3196
+ input: window.__mcpToolInput,
3197
+ }),
3198
+ container
3199
+ );
3200
+ }
3201
+ })();
3202
+ </script>`;
3203
+ } else {
3204
+ return `
3205
+ <!-- Component Render Script (ESM - waits for React) -->
3206
+ <script type="module">
3207
+ function renderComponent() {
3208
+ ${wrappedCode}
3209
+
3210
+ // Get the component
3211
+ var Component = window.__frontmcp_component.default || window.__frontmcp_component;
3212
+
3213
+ // Render the component
3214
+ var container = document.getElementById('${rootId}');
3215
+ if (container && window.ReactDOM && window.ReactDOM.createRoot) {
3216
+ var root = window.ReactDOM.createRoot(container);
3217
+ root.render(React.createElement(Component, {
3218
+ output: window.__mcpToolOutput,
3219
+ input: window.__mcpToolInput,
3220
+ }));
3221
+ }
3222
+ }
3223
+
3224
+ // Wait for React to be ready
3225
+ if (window.__reactReady) {
3226
+ renderComponent();
3227
+ } else {
3228
+ window.addEventListener('react:ready', renderComponent);
3229
+ }
3230
+ </script>`;
3231
+ }
3232
+ }
3233
+ /**
3234
+ * Assemble the complete static HTML document.
3235
+ */
3236
+ assembleStaticHTML(parts) {
3237
+ return `<!DOCTYPE html>
3238
+ <html lang="en">
3239
+ <head>
3240
+ <title>${(0, import_utils.escapeHtml)(parts.title)}</title>
3241
+ ${parts.head}
3242
+ ${parts.reactRuntime}
3243
+ ${parts.frontmcpRuntime}
3244
+ ${parts.dataScript}
3245
+ </head>
3246
+ <body>
3247
+ <div id="${parts.rootId}" class="frontmcp-loading">
3248
+ <div class="frontmcp-spinner"></div>
3249
+ </div>
3250
+ ${parts.componentScript}
3251
+ </body>
3252
+ </html>`;
3253
+ }
3254
+ };
3255
+ function createBundler(options) {
3256
+ return new InMemoryBundler(options);
3257
+ }
3258
+
3259
+ // libs/ui/src/bundler/file-cache/storage/index.ts
3260
+ init_interface();
3261
+ init_filesystem();
3262
+ init_redis();
3263
+
3264
+ // libs/ui/src/bundler/file-cache/hash-calculator.ts
3265
+ var import_crypto2 = require("crypto");
3266
+ var import_promises2 = require("fs/promises");
3267
+ var import_fs2 = require("fs");
3268
+ var import_path2 = require("path");
3269
+ function sha256(content) {
3270
+ return (0, import_crypto2.createHash)("sha256").update(content, "utf8").digest("hex");
3271
+ }
3272
+ function sha256Buffer(buffer) {
3273
+ return (0, import_crypto2.createHash)("sha256").update(buffer).digest("hex");
3274
+ }
3275
+ async function hashFile(filePath) {
3276
+ try {
3277
+ const content = await (0, import_promises2.readFile)(filePath);
3278
+ return sha256Buffer(content);
3279
+ } catch {
3280
+ return void 0;
3281
+ }
3282
+ }
3283
+ async function hashFiles(filePaths) {
3284
+ const hashes = [];
3285
+ for (const filePath of filePaths.sort()) {
3286
+ const hash = await hashFile(filePath);
3287
+ if (hash) {
3288
+ hashes.push(`${filePath}:${hash}`);
3289
+ }
3290
+ }
3291
+ return sha256(hashes.join("\n"));
3292
+ }
3293
+ async function calculateComponentHash(options) {
3294
+ const {
3295
+ entryPath,
3296
+ baseDir = (0, import_path2.dirname)(entryPath),
3297
+ externals = [],
3298
+ dependencies = {},
3299
+ bundleOptions = {},
3300
+ maxDepth = 10
3301
+ } = options;
3302
+ const absoluteEntryPath = (0, import_path2.resolve)(entryPath);
3303
+ const files = /* @__PURE__ */ new Set();
3304
+ const fileHashes = {};
3305
+ await collectLocalDependencies(absoluteEntryPath, baseDir, files, maxDepth, 0);
3306
+ for (const file of files) {
3307
+ const hash = await hashFile(file);
3308
+ if (hash) {
3309
+ fileHashes[file] = hash;
3310
+ }
3311
+ }
3312
+ const sortedFiles = Array.from(files).sort();
3313
+ const fileHashContent = sortedFiles.map((f) => `${f}:${fileHashes[f] || "missing"}`).join("\n");
3314
+ const filesHash = sha256(fileHashContent);
3315
+ const optionsHash = sha256(JSON.stringify(sortedObject(bundleOptions)));
3316
+ const dependenciesHash = sha256(JSON.stringify(sortedObject(dependencies)));
3317
+ const combinedHash = sha256([filesHash, optionsHash, dependenciesHash].join(":"));
3318
+ return {
3319
+ hash: combinedHash,
3320
+ entryHash: fileHashes[absoluteEntryPath] || "",
3321
+ files: sortedFiles,
3322
+ fileHashes,
3323
+ optionsHash,
3324
+ dependenciesHash
3325
+ };
3326
+ }
3327
+ async function calculateQuickHash(entryPath, bundleOptions) {
3328
+ const entryHash = await hashFile(entryPath);
3329
+ const optionsHash = bundleOptions ? sha256(JSON.stringify(sortedObject(bundleOptions))) : "";
3330
+ return sha256(`${entryHash || "missing"}:${optionsHash}`);
3331
+ }
3332
+ async function collectLocalDependencies(filePath, baseDir, collected, maxDepth, currentDepth) {
3333
+ if (currentDepth >= maxDepth) return;
3334
+ if (collected.has(filePath)) return;
3335
+ if (!(0, import_fs2.existsSync)(filePath)) return;
3336
+ collected.add(filePath);
3337
+ try {
3338
+ const content = await (0, import_promises2.readFile)(filePath, "utf8");
3339
+ const imports = extractImportPaths(content);
3340
+ for (const importPath of imports) {
3341
+ if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
3342
+ continue;
3343
+ }
3344
+ const resolvedPath = resolveImportPath(importPath, (0, import_path2.dirname)(filePath));
3345
+ if (resolvedPath && (0, import_fs2.existsSync)(resolvedPath)) {
3346
+ await collectLocalDependencies(resolvedPath, baseDir, collected, maxDepth, currentDepth + 1);
3347
+ }
3348
+ }
3349
+ } catch {
3350
+ }
3351
+ }
3352
+ function extractImportPaths(source) {
3353
+ const paths = [];
3354
+ const importRegex = /import\s+(?:[^'"]+\s+from\s+)?['"]([^'"]+)['"]/g;
3355
+ let match;
3356
+ while ((match = importRegex.exec(source)) !== null) {
3357
+ paths.push(match[1]);
3358
+ }
3359
+ const exportRegex = /export\s+(?:\*|{[^}]+})\s+from\s+['"]([^'"]+)['"]/g;
3360
+ while ((match = exportRegex.exec(source)) !== null) {
3361
+ paths.push(match[1]);
3362
+ }
3363
+ const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
3364
+ while ((match = requireRegex.exec(source)) !== null) {
3365
+ paths.push(match[1]);
3366
+ }
3367
+ const dynamicRegex = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
3368
+ while ((match = dynamicRegex.exec(source)) !== null) {
3369
+ paths.push(match[1]);
3370
+ }
3371
+ return [...new Set(paths)];
3372
+ }
3373
+ function resolveImportPath(importPath, fromDir) {
3374
+ const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3375
+ for (const ext of extensions) {
3376
+ const fullPath = (0, import_path2.join)(fromDir, importPath + ext);
3377
+ if ((0, import_fs2.existsSync)(fullPath)) {
3378
+ return fullPath;
3379
+ }
3380
+ }
3381
+ for (const ext of extensions) {
3382
+ const indexPath = (0, import_path2.join)(fromDir, importPath, `index${ext}`);
3383
+ if ((0, import_fs2.existsSync)(indexPath)) {
3384
+ return indexPath;
3385
+ }
3386
+ }
3387
+ return void 0;
3388
+ }
3389
+ function sortedObject(obj) {
3390
+ const sorted = {};
3391
+ const keys = Object.keys(obj).sort();
3392
+ for (const key of keys) {
3393
+ const value = obj[key];
3394
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3395
+ sorted[key] = sortedObject(value);
3396
+ } else {
3397
+ sorted[key] = value;
3398
+ }
3399
+ }
3400
+ return sorted;
3401
+ }
3402
+ function generateBuildId() {
3403
+ const timestamp = Date.now().toString(36);
3404
+ const random = Math.random().toString(36).substring(2, 10);
3405
+ return `${timestamp}-${random}`;
3406
+ }
3407
+ function buildIdFromHash(hash) {
3408
+ return hash.substring(0, 12);
3409
+ }
3410
+
3411
+ // libs/ui/src/bundler/file-cache/component-builder.ts
3412
+ var import_promises3 = require("fs/promises");
3413
+ var import_fs3 = require("fs");
3414
+ var import_path3 = require("path");
3415
+ var import_crypto3 = require("crypto");
3416
+ var import_dependency = require("@frontmcp/uipack/dependency");
3417
+ var ComponentBuilder = class {
3418
+ storage;
3419
+ esbuild = null;
3420
+ constructor(storage) {
3421
+ this.storage = storage;
3422
+ }
3423
+ /**
3424
+ * Build a component from a file path.
3425
+ */
3426
+ async build(options) {
3427
+ const startTime = performance.now();
3428
+ const {
3429
+ entryPath,
3430
+ toolName,
3431
+ externals = [],
3432
+ dependencies = {},
3433
+ bundleOptions = {},
3434
+ platform = "unknown",
3435
+ skipCache = false,
3436
+ ssr = false,
3437
+ ssrContext = {},
3438
+ executeCode: executeCode3
3439
+ } = options;
3440
+ const absoluteEntryPath = (0, import_path3.resolve)(entryPath);
3441
+ if (!(0, import_fs3.existsSync)(absoluteEntryPath)) {
3442
+ throw new Error(`Entry file not found: ${absoluteEntryPath}`);
3443
+ }
3444
+ const hashResult = await calculateComponentHash({
3445
+ entryPath: absoluteEntryPath,
3446
+ externals,
3447
+ dependencies,
3448
+ bundleOptions
3449
+ });
3450
+ if (!skipCache) {
3451
+ const cached = await this.storage.get(hashResult.hash);
3452
+ if (cached) {
3453
+ return {
3454
+ manifest: cached,
3455
+ cached: true,
3456
+ buildTimeMs: performance.now() - startTime
3457
+ };
3458
+ }
3459
+ }
3460
+ const source = await (0, import_promises3.readFile)(absoluteEntryPath, "utf8");
3461
+ const resolver = new import_dependency.DependencyResolver({ platform });
3462
+ const resolvedDeps = [];
3463
+ for (const pkg of externals) {
3464
+ try {
3465
+ const override = dependencies[pkg];
3466
+ const resolved = resolver.resolve(pkg, override);
3467
+ if (resolved) {
3468
+ resolvedDeps.push(resolved);
3469
+ }
3470
+ } catch (error) {
3471
+ console.warn(`Failed to resolve external "${pkg}": ${error}`);
3472
+ }
3473
+ }
3474
+ const allExternals = new Set(externals);
3475
+ for (const dep of resolvedDeps) {
3476
+ const entry = resolver.getRegistry()[dep.packageName];
3477
+ if (entry?.providers) {
3478
+ const providerConfig = Object.values(entry.providers)[0];
3479
+ if (providerConfig?.peerDependencies) {
3480
+ for (const peer of providerConfig.peerDependencies) {
3481
+ if (!allExternals.has(peer)) {
3482
+ allExternals.add(peer);
3483
+ try {
3484
+ const peerOverride = dependencies[peer];
3485
+ const resolved = resolver.resolve(peer, peerOverride);
3486
+ if (resolved) {
3487
+ resolvedDeps.push(resolved);
3488
+ }
3489
+ } catch {
3490
+ }
3491
+ }
3492
+ }
3493
+ }
3494
+ }
3495
+ }
3496
+ const importMap = (0, import_dependency.createImportMap)(resolvedDeps);
3497
+ const bundleResult = await this.bundleComponent({
3498
+ source,
3499
+ entryPath: absoluteEntryPath,
3500
+ externals: Array.from(allExternals),
3501
+ bundleOptions
3502
+ });
3503
+ let ssrHtml;
3504
+ if (ssr) {
3505
+ ssrHtml = await this.renderSSR(bundleResult.code, ssrContext, resolvedDeps, executeCode3);
3506
+ }
3507
+ const manifest = {
3508
+ version: "1.0",
3509
+ buildId: (0, import_crypto3.randomUUID)(),
3510
+ toolName,
3511
+ entryPath: absoluteEntryPath,
3512
+ contentHash: hashResult.hash,
3513
+ dependencies: resolvedDeps,
3514
+ outputs: {
3515
+ code: bundleResult.code,
3516
+ sourceMap: bundleResult.map,
3517
+ ssrHtml
3518
+ },
3519
+ importMap,
3520
+ metadata: {
3521
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3522
+ buildTimeMs: performance.now() - startTime,
3523
+ totalSize: Buffer.byteLength(bundleResult.code, "utf8"),
3524
+ bundlerVersion: bundleResult.bundlerVersion
3525
+ }
3526
+ };
3527
+ await this.storage.set(hashResult.hash, manifest);
3528
+ return {
3529
+ manifest,
3530
+ cached: false,
3531
+ buildTimeMs: performance.now() - startTime
3532
+ };
3533
+ }
3534
+ /**
3535
+ * Build multiple components.
3536
+ */
3537
+ async buildMany(options) {
3538
+ return Promise.all(options.map((opt) => this.build(opt)));
3539
+ }
3540
+ /**
3541
+ * Check if a component needs rebuilding.
3542
+ */
3543
+ async needsRebuild(options) {
3544
+ const absoluteEntryPath = (0, import_path3.resolve)(options.entryPath);
3545
+ const hashResult = await calculateComponentHash({
3546
+ entryPath: absoluteEntryPath,
3547
+ externals: options.externals,
3548
+ dependencies: options.dependencies,
3549
+ bundleOptions: options.bundleOptions
3550
+ });
3551
+ const cached = await this.storage.has(hashResult.hash);
3552
+ return !cached;
3553
+ }
3554
+ /**
3555
+ * Get a cached build if it exists.
3556
+ */
3557
+ async getCached(options) {
3558
+ const absoluteEntryPath = (0, import_path3.resolve)(options.entryPath);
3559
+ const hashResult = await calculateComponentHash({
3560
+ entryPath: absoluteEntryPath,
3561
+ externals: options.externals,
3562
+ dependencies: options.dependencies,
3563
+ bundleOptions: options.bundleOptions
3564
+ });
3565
+ return this.storage.get(hashResult.hash);
3566
+ }
3567
+ /**
3568
+ * Invalidate a cached build.
3569
+ */
3570
+ async invalidate(contentHash) {
3571
+ return this.storage.delete(contentHash);
3572
+ }
3573
+ /**
3574
+ * Generate complete HTML for a built component.
3575
+ */
3576
+ generateHTML(manifest, minify = false) {
3577
+ const parts = [];
3578
+ const dependencyHtml = (0, import_dependency.generateDependencyHTML)(manifest.dependencies, { minify });
3579
+ parts.push(dependencyHtml);
3580
+ parts.push(`<script type="module">${manifest.outputs.code}</script>`);
3581
+ return parts.join(minify ? "" : "\n");
3582
+ }
3583
+ /**
3584
+ * Bundle a component using esbuild.
3585
+ */
3586
+ async bundleComponent(options) {
3587
+ const { source, entryPath, externals, bundleOptions } = options;
3588
+ if (!this.esbuild) {
3589
+ try {
3590
+ this.esbuild = await import("esbuild");
3591
+ } catch {
3592
+ throw new Error("esbuild is required for component building. Install with: npm install esbuild");
3593
+ }
3594
+ }
3595
+ const ext = (0, import_path3.extname)(entryPath).toLowerCase();
3596
+ const loader = ext === ".tsx" ? "tsx" : ext === ".ts" ? "ts" : ext === ".jsx" ? "jsx" : "js";
3597
+ try {
3598
+ const result = await this.esbuild.transform(source, {
3599
+ loader,
3600
+ format: "esm",
3601
+ minify: bundleOptions.minify ?? process.env["NODE_ENV"] === "production",
3602
+ sourcemap: bundleOptions.sourceMaps ? "inline" : false,
3603
+ target: bundleOptions.target ?? "es2020",
3604
+ treeShaking: bundleOptions.treeShake ?? true,
3605
+ jsx: "automatic",
3606
+ jsxImportSource: bundleOptions.jsxImportSource ?? "react",
3607
+ // Mark externals for later import map resolution
3608
+ banner: externals.length > 0 ? `/* externals: ${externals.join(", ")} */` : void 0
3609
+ });
3610
+ return {
3611
+ code: result.code,
3612
+ map: result.map || void 0,
3613
+ bundlerVersion: this.esbuild.version
3614
+ };
3615
+ } catch (error) {
3616
+ throw new Error(`Bundle failed for ${entryPath}: ${error}`);
3617
+ }
3618
+ }
3619
+ /**
3620
+ * Perform server-side rendering.
3621
+ */
3622
+ async renderSSR(code, context, dependencies, executeCode3) {
3623
+ const hasReact = dependencies.some((d) => d.packageName === "react");
3624
+ if (!hasReact) {
3625
+ console.warn("SSR requires React as an external dependency");
3626
+ return void 0;
3627
+ }
3628
+ try {
3629
+ const React = await import("react");
3630
+ const ReactDOMServer = await import("react-dom/server");
3631
+ const exports2 = {};
3632
+ const module2 = { exports: exports2 };
3633
+ if (executeCode3) {
3634
+ executeCode3(code, exports2, module2, React);
3635
+ } else {
3636
+ const fn = new Function("exports", "module", "React", code);
3637
+ fn(exports2, module2, React);
3638
+ }
3639
+ const Component = module2.exports.default || module2.exports;
3640
+ if (typeof Component !== "function") {
3641
+ console.warn("SSR: No default component export found");
3642
+ return void 0;
3643
+ }
3644
+ const element = React.createElement(Component, context);
3645
+ return ReactDOMServer.renderToString(element);
3646
+ } catch (error) {
3647
+ console.warn(`SSR failed: ${error}`);
3648
+ return void 0;
3649
+ }
3650
+ }
3651
+ };
3652
+ async function createFilesystemBuilder(cacheDir = ".frontmcp-cache/builds") {
3653
+ const { FilesystemStorage: FilesystemStorage2 } = await Promise.resolve().then(() => (init_filesystem(), filesystem_exports));
3654
+ const storage = new FilesystemStorage2({ cacheDir });
3655
+ await storage.initialize();
3656
+ return new ComponentBuilder(storage);
3657
+ }
3658
+ async function createRedisBuilder(redisClient, keyPrefix = "frontmcp:ui:build:") {
3659
+ const { RedisStorage: RedisStorage2 } = await Promise.resolve().then(() => (init_redis(), redis_exports));
3660
+ const storage = new RedisStorage2({
3661
+ client: redisClient,
3662
+ keyPrefix
3663
+ });
3664
+ await storage.initialize();
3665
+ return new ComponentBuilder(storage);
3666
+ }
3667
+ // Annotate the CommonJS export names for ESM import in node:
3668
+ 0 && (module.exports = {
3669
+ BundlerCache,
3670
+ ComponentBuilder,
3671
+ DEFAULT_BUNDLER_OPTIONS,
3672
+ DEFAULT_BUNDLE_OPTIONS,
3673
+ DEFAULT_SECURITY_POLICY,
3674
+ DEFAULT_STATIC_HTML_OPTIONS,
3675
+ DEFAULT_STORAGE_OPTIONS,
3676
+ ExecutionError,
3677
+ FilesystemStorage,
3678
+ InMemoryBundler,
3679
+ RedisStorage,
3680
+ STATIC_HTML_CDN,
3681
+ SecurityError,
3682
+ buildIdFromHash,
3683
+ calculateComponentHash,
3684
+ calculateManifestSize,
3685
+ calculateQuickHash,
3686
+ createBundler,
3687
+ createCacheKey,
3688
+ createFilesystemBuilder,
3689
+ createFilesystemStorage,
3690
+ createRedisBuilder,
3691
+ createRedisStorage,
3692
+ executeCode,
3693
+ executeDefault,
3694
+ generateBuildId,
3695
+ getCdnTypeForPlatform,
3696
+ hashContent,
3697
+ hashFile,
3698
+ hashFiles,
3699
+ isExecutionError,
3700
+ mergePolicy,
3701
+ sha256,
3702
+ sha256Buffer,
3703
+ throwOnViolations,
3704
+ validateImports,
3705
+ validateSize,
3706
+ validateSource
3707
+ });