@frontmcp/ui 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/bridge/core/bridge-factory.d.ts +1 -0
  2. package/bridge/core/bridge-factory.d.ts.map +1 -1
  3. package/bridge/index.d.ts +1 -1
  4. package/bridge/index.d.ts.map +1 -1
  5. package/bridge/index.js +39 -881
  6. package/bundler/browser-components.d.ts +42 -0
  7. package/bundler/browser-components.d.ts.map +1 -0
  8. package/bundler/bundler.d.ts +78 -4
  9. package/bundler/bundler.d.ts.map +1 -1
  10. package/bundler/index.d.ts +8 -8
  11. package/bundler/index.d.ts.map +1 -1
  12. package/bundler/index.js +1315 -1854
  13. package/bundler/types.d.ts +188 -7
  14. package/bundler/types.d.ts.map +1 -1
  15. package/esm/bridge/{index.js → index.mjs} +40 -877
  16. package/esm/bundler/{index.js → index.mjs} +1391 -1895
  17. package/esm/{index.js → index.mjs} +215 -3091
  18. package/esm/layouts/{index.js → index.mjs} +3 -3
  19. package/esm/package.json +9 -8
  20. package/esm/react/index.mjs +1183 -0
  21. package/esm/renderers/index.mjs +611 -0
  22. package/esm/universal/{index.js → index.mjs} +266 -70
  23. package/index.d.ts +1 -4
  24. package/index.d.ts.map +1 -1
  25. package/index.js +208 -3113
  26. package/layouts/base.d.ts.map +1 -1
  27. package/layouts/index.js +3 -3
  28. package/layouts/presets.d.ts.map +1 -1
  29. package/package.json +9 -8
  30. package/react/Badge.d.ts.map +1 -1
  31. package/react/hooks/context.d.ts.map +1 -1
  32. package/react/index.d.ts +0 -1
  33. package/react/index.d.ts.map +1 -1
  34. package/react/index.js +57 -2001
  35. package/react/types.d.ts.map +1 -1
  36. package/renderers/index.d.ts +9 -4
  37. package/renderers/index.d.ts.map +1 -1
  38. package/renderers/index.js +328 -88
  39. package/renderers/mdx.renderer.d.ts +99 -0
  40. package/renderers/mdx.renderer.d.ts.map +1 -0
  41. package/renderers/react.renderer.d.ts +22 -13
  42. package/renderers/react.renderer.d.ts.map +1 -1
  43. package/renderers/transpiler.d.ts +49 -0
  44. package/renderers/transpiler.d.ts.map +1 -0
  45. package/universal/cached-runtime.d.ts +25 -1
  46. package/universal/cached-runtime.d.ts.map +1 -1
  47. package/universal/index.js +266 -70
  48. package/universal/runtime-builder.d.ts.map +1 -1
  49. package/universal/types.d.ts.map +1 -1
  50. package/web-components/elements/fmcp-input.d.ts.map +1 -1
  51. package/web-components/elements/fmcp-select.d.ts.map +1 -1
  52. package/web-components/index.d.ts +0 -1
  53. package/web-components/index.d.ts.map +1 -1
  54. package/bundler/cache.d.ts +0 -173
  55. package/bundler/cache.d.ts.map +0 -1
  56. package/bundler/file-cache/component-builder.d.ts +0 -167
  57. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  58. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  59. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  60. package/bundler/file-cache/index.d.ts +0 -12
  61. package/bundler/file-cache/index.d.ts.map +0 -1
  62. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  63. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  64. package/bundler/file-cache/storage/index.d.ts +0 -11
  65. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  66. package/bundler/file-cache/storage/interface.d.ts +0 -152
  67. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  68. package/bundler/file-cache/storage/redis.d.ts +0 -139
  69. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  70. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  71. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  72. package/bundler/sandbox/executor.d.ts +0 -14
  73. package/bundler/sandbox/executor.d.ts.map +0 -1
  74. package/bundler/sandbox/policy.d.ts +0 -62
  75. package/bundler/sandbox/policy.d.ts.map +0 -1
  76. package/esm/bridge/adapters/base-adapter.d.ts +0 -104
  77. package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
  78. package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
  79. package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
  80. package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
  81. package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
  82. package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
  83. package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
  84. package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
  85. package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
  86. package/esm/bridge/adapters/index.d.ts +0 -26
  87. package/esm/bridge/adapters/index.d.ts.map +0 -1
  88. package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
  89. package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
  90. package/esm/bridge/core/adapter-registry.d.ts +0 -122
  91. package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
  92. package/esm/bridge/core/bridge-factory.d.ts +0 -199
  93. package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
  94. package/esm/bridge/core/index.d.ts +0 -10
  95. package/esm/bridge/core/index.d.ts.map +0 -1
  96. package/esm/bridge/index.d.ts +0 -62
  97. package/esm/bridge/index.d.ts.map +0 -1
  98. package/esm/bridge/runtime/iife-generator.d.ts +0 -62
  99. package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
  100. package/esm/bridge/runtime/index.d.ts +0 -10
  101. package/esm/bridge/runtime/index.d.ts.map +0 -1
  102. package/esm/bridge/types.d.ts +0 -386
  103. package/esm/bridge/types.d.ts.map +0 -1
  104. package/esm/bundler/bundler.d.ts +0 -208
  105. package/esm/bundler/bundler.d.ts.map +0 -1
  106. package/esm/bundler/cache.d.ts +0 -173
  107. package/esm/bundler/cache.d.ts.map +0 -1
  108. package/esm/bundler/file-cache/component-builder.d.ts +0 -167
  109. package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
  110. package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
  111. package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  112. package/esm/bundler/file-cache/index.d.ts +0 -12
  113. package/esm/bundler/file-cache/index.d.ts.map +0 -1
  114. package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
  115. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  116. package/esm/bundler/file-cache/storage/index.d.ts +0 -11
  117. package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
  118. package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
  119. package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
  120. package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
  121. package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
  122. package/esm/bundler/index.d.ts +0 -43
  123. package/esm/bundler/index.d.ts.map +0 -1
  124. package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
  125. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  126. package/esm/bundler/sandbox/executor.d.ts +0 -14
  127. package/esm/bundler/sandbox/executor.d.ts.map +0 -1
  128. package/esm/bundler/sandbox/policy.d.ts +0 -62
  129. package/esm/bundler/sandbox/policy.d.ts.map +0 -1
  130. package/esm/bundler/types.d.ts +0 -702
  131. package/esm/bundler/types.d.ts.map +0 -1
  132. package/esm/components/alert.d.ts +0 -66
  133. package/esm/components/alert.d.ts.map +0 -1
  134. package/esm/components/alert.schema.d.ts +0 -98
  135. package/esm/components/alert.schema.d.ts.map +0 -1
  136. package/esm/components/avatar.d.ts +0 -77
  137. package/esm/components/avatar.d.ts.map +0 -1
  138. package/esm/components/avatar.schema.d.ts +0 -170
  139. package/esm/components/avatar.schema.d.ts.map +0 -1
  140. package/esm/components/badge.d.ts +0 -64
  141. package/esm/components/badge.d.ts.map +0 -1
  142. package/esm/components/badge.schema.d.ts +0 -91
  143. package/esm/components/badge.schema.d.ts.map +0 -1
  144. package/esm/components/button.d.ts +0 -100
  145. package/esm/components/button.d.ts.map +0 -1
  146. package/esm/components/button.schema.d.ts +0 -120
  147. package/esm/components/button.schema.d.ts.map +0 -1
  148. package/esm/components/card.d.ts +0 -53
  149. package/esm/components/card.d.ts.map +0 -1
  150. package/esm/components/card.schema.d.ts +0 -93
  151. package/esm/components/card.schema.d.ts.map +0 -1
  152. package/esm/components/form.d.ts +0 -212
  153. package/esm/components/form.d.ts.map +0 -1
  154. package/esm/components/form.schema.d.ts +0 -365
  155. package/esm/components/form.schema.d.ts.map +0 -1
  156. package/esm/components/index.d.ts +0 -29
  157. package/esm/components/index.d.ts.map +0 -1
  158. package/esm/components/list.d.ts +0 -121
  159. package/esm/components/list.d.ts.map +0 -1
  160. package/esm/components/list.schema.d.ts +0 -129
  161. package/esm/components/list.schema.d.ts.map +0 -1
  162. package/esm/components/modal.d.ts +0 -100
  163. package/esm/components/modal.d.ts.map +0 -1
  164. package/esm/components/modal.schema.d.ts +0 -151
  165. package/esm/components/modal.schema.d.ts.map +0 -1
  166. package/esm/components/table.d.ts +0 -91
  167. package/esm/components/table.d.ts.map +0 -1
  168. package/esm/components/table.schema.d.ts +0 -123
  169. package/esm/components/table.schema.d.ts.map +0 -1
  170. package/esm/index.d.ts +0 -40
  171. package/esm/index.d.ts.map +0 -1
  172. package/esm/layouts/base.d.ts +0 -86
  173. package/esm/layouts/base.d.ts.map +0 -1
  174. package/esm/layouts/index.d.ts +0 -8
  175. package/esm/layouts/index.d.ts.map +0 -1
  176. package/esm/layouts/presets.d.ts +0 -134
  177. package/esm/layouts/presets.d.ts.map +0 -1
  178. package/esm/pages/consent.d.ts +0 -117
  179. package/esm/pages/consent.d.ts.map +0 -1
  180. package/esm/pages/error.d.ts +0 -101
  181. package/esm/pages/error.d.ts.map +0 -1
  182. package/esm/pages/index.d.ts +0 -9
  183. package/esm/pages/index.d.ts.map +0 -1
  184. package/esm/pages/index.js +0 -1036
  185. package/esm/react/Alert.d.ts +0 -101
  186. package/esm/react/Alert.d.ts.map +0 -1
  187. package/esm/react/Badge.d.ts +0 -100
  188. package/esm/react/Badge.d.ts.map +0 -1
  189. package/esm/react/Button.d.ts +0 -108
  190. package/esm/react/Button.d.ts.map +0 -1
  191. package/esm/react/Card.d.ts +0 -103
  192. package/esm/react/Card.d.ts.map +0 -1
  193. package/esm/react/hooks/context.d.ts +0 -179
  194. package/esm/react/hooks/context.d.ts.map +0 -1
  195. package/esm/react/hooks/index.d.ts +0 -42
  196. package/esm/react/hooks/index.d.ts.map +0 -1
  197. package/esm/react/hooks/tools.d.ts +0 -284
  198. package/esm/react/hooks/tools.d.ts.map +0 -1
  199. package/esm/react/index.d.ts +0 -80
  200. package/esm/react/index.d.ts.map +0 -1
  201. package/esm/react/index.js +0 -3124
  202. package/esm/react/types.d.ts +0 -105
  203. package/esm/react/types.d.ts.map +0 -1
  204. package/esm/react/utils.d.ts +0 -43
  205. package/esm/react/utils.d.ts.map +0 -1
  206. package/esm/render/index.d.ts +0 -8
  207. package/esm/render/index.d.ts.map +0 -1
  208. package/esm/render/prerender.d.ts +0 -57
  209. package/esm/render/prerender.d.ts.map +0 -1
  210. package/esm/renderers/index.d.ts +0 -21
  211. package/esm/renderers/index.d.ts.map +0 -1
  212. package/esm/renderers/index.js +0 -381
  213. package/esm/renderers/react.adapter.d.ts +0 -70
  214. package/esm/renderers/react.adapter.d.ts.map +0 -1
  215. package/esm/renderers/react.renderer.d.ts +0 -96
  216. package/esm/renderers/react.renderer.d.ts.map +0 -1
  217. package/esm/universal/UniversalApp.d.ts +0 -108
  218. package/esm/universal/UniversalApp.d.ts.map +0 -1
  219. package/esm/universal/cached-runtime.d.ts +0 -115
  220. package/esm/universal/cached-runtime.d.ts.map +0 -1
  221. package/esm/universal/context.d.ts +0 -122
  222. package/esm/universal/context.d.ts.map +0 -1
  223. package/esm/universal/index.d.ts +0 -57
  224. package/esm/universal/index.d.ts.map +0 -1
  225. package/esm/universal/renderers/html.renderer.d.ts +0 -37
  226. package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
  227. package/esm/universal/renderers/index.d.ts +0 -112
  228. package/esm/universal/renderers/index.d.ts.map +0 -1
  229. package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
  230. package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
  231. package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
  232. package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
  233. package/esm/universal/renderers/react.renderer.d.ts +0 -46
  234. package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
  235. package/esm/universal/runtime-builder.d.ts +0 -33
  236. package/esm/universal/runtime-builder.d.ts.map +0 -1
  237. package/esm/universal/store.d.ts +0 -135
  238. package/esm/universal/store.d.ts.map +0 -1
  239. package/esm/universal/types.d.ts +0 -199
  240. package/esm/universal/types.d.ts.map +0 -1
  241. package/esm/web-components/core/attribute-parser.d.ts +0 -82
  242. package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
  243. package/esm/web-components/core/base-element.d.ts +0 -197
  244. package/esm/web-components/core/base-element.d.ts.map +0 -1
  245. package/esm/web-components/core/index.d.ts +0 -9
  246. package/esm/web-components/core/index.d.ts.map +0 -1
  247. package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
  248. package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
  249. package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
  250. package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
  251. package/esm/web-components/elements/fmcp-button.d.ts +0 -117
  252. package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
  253. package/esm/web-components/elements/fmcp-card.d.ts +0 -53
  254. package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
  255. package/esm/web-components/elements/fmcp-input.d.ts +0 -96
  256. package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
  257. package/esm/web-components/elements/fmcp-select.d.ts +0 -100
  258. package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
  259. package/esm/web-components/elements/index.d.ts +0 -13
  260. package/esm/web-components/elements/index.d.ts.map +0 -1
  261. package/esm/web-components/index.d.ts +0 -50
  262. package/esm/web-components/index.d.ts.map +0 -1
  263. package/esm/web-components/register.d.ts +0 -57
  264. package/esm/web-components/register.d.ts.map +0 -1
  265. package/esm/web-components/types.d.ts +0 -122
  266. package/esm/web-components/types.d.ts.map +0 -1
  267. package/esm/widgets/index.d.ts +0 -8
  268. package/esm/widgets/index.d.ts.map +0 -1
  269. package/esm/widgets/index.js +0 -883
  270. package/esm/widgets/progress.d.ts +0 -133
  271. package/esm/widgets/progress.d.ts.map +0 -1
  272. package/esm/widgets/resource.d.ts +0 -163
  273. package/esm/widgets/resource.d.ts.map +0 -1
  274. package/pages/consent.d.ts +0 -117
  275. package/pages/consent.d.ts.map +0 -1
  276. package/pages/error.d.ts +0 -101
  277. package/pages/error.d.ts.map +0 -1
  278. package/pages/index.d.ts +0 -9
  279. package/pages/index.d.ts.map +0 -1
  280. package/pages/index.js +0 -1065
  281. package/react/utils.d.ts +0 -43
  282. package/react/utils.d.ts.map +0 -1
  283. package/widgets/index.d.ts +0 -8
  284. package/widgets/index.d.ts.map +0 -1
  285. package/widgets/index.js +0 -910
  286. package/widgets/progress.d.ts +0 -133
  287. package/widgets/progress.d.ts.map +0 -1
  288. package/widgets/resource.d.ts +0 -163
  289. package/widgets/resource.d.ts.map +0 -1
  290. /package/esm/components/{index.js → index.mjs} +0 -0
  291. /package/esm/render/{index.js → index.mjs} +0 -0
  292. /package/esm/web-components/{index.js → index.mjs} +0 -0
@@ -1075,7 +1075,7 @@ function buildUniversalRuntime(options) {
1075
1075
  }
1076
1076
  let script = parts.join("\n");
1077
1077
  if (options.minify) {
1078
- script = script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1078
+ script = script.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1079
1079
  }
1080
1080
  return {
1081
1081
  script,
@@ -1086,12 +1086,14 @@ function buildUniversalRuntime(options) {
1086
1086
  function buildMinimalRuntime(options) {
1087
1087
  let script = buildStoreRuntime();
1088
1088
  if (options.minify) {
1089
- script = script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1089
+ script = script.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1090
1090
  }
1091
1091
  return script;
1092
1092
  }
1093
1093
 
1094
1094
  // libs/ui/src/universal/cached-runtime.ts
1095
+ import { getMCPBridgeScript } from "@frontmcp/uipack/runtime";
1096
+ import { buildUIComponentsRuntime as buildBrowserUIComponents } from "@frontmcp/uipack/build";
1095
1097
  var RUNTIME_PLACEHOLDERS = {
1096
1098
  /** Placeholder for transpiled component code */
1097
1099
  COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/",
@@ -1117,6 +1119,7 @@ function generateCacheKey(options) {
1117
1119
  options.includeMarkdown ? "md" : "",
1118
1120
  options.includeMdx ? "mdx" : "",
1119
1121
  options.minify ? "min" : "",
1122
+ options.includeBridge ? "bridge" : "",
1120
1123
  securityKey
1121
1124
  ].filter(Boolean).join(":");
1122
1125
  }
@@ -1160,6 +1163,17 @@ function buildStoreRuntime2() {
1160
1163
  context: state,
1161
1164
  setContext: function(ctx) {
1162
1165
  this.setState(ctx);
1166
+ },
1167
+ // Dynamic mode: update output and re-render
1168
+ updateOutput: function(output) {
1169
+ this.setState({ output: output, loading: false });
1170
+ // Also update the global window variable for compatibility
1171
+ window.__mcpToolOutput = output;
1172
+ },
1173
+ // Dynamic mode: update input and re-render
1174
+ updateInput: function(input) {
1175
+ this.setState({ input: input });
1176
+ window.__mcpToolInput = input;
1163
1177
  }
1164
1178
  };
1165
1179
 
@@ -1184,6 +1198,32 @@ function buildStoreRuntime2() {
1184
1198
  window.useContent = function() {
1185
1199
  return window.useFrontMCPStore().content;
1186
1200
  };
1201
+
1202
+ // Connect to MCP Bridge for platform data detection
1203
+ function initFromBridge() {
1204
+ // Check for data from mcpBridge (handles OpenAI, ext-apps, etc.)
1205
+ if (window.mcpBridge && window.mcpBridge.toolOutput != null) {
1206
+ window.__frontmcp.setState({
1207
+ output: window.mcpBridge.toolOutput,
1208
+ loading: false
1209
+ });
1210
+ }
1211
+
1212
+ // Subscribe to bridge updates via onToolResult
1213
+ if (window.mcpBridge && window.mcpBridge.onToolResult) {
1214
+ window.mcpBridge.onToolResult(function(result) {
1215
+ window.__frontmcp.updateOutput(result);
1216
+ });
1217
+ }
1218
+ }
1219
+
1220
+ // Initialize from bridge when ready
1221
+ if (window.mcpBridge) {
1222
+ initFromBridge();
1223
+ } else {
1224
+ // Wait for bridge to be ready
1225
+ window.addEventListener('mcp:bridge-ready', initFromBridge);
1226
+ }
1187
1227
  })();
1188
1228
  `;
1189
1229
  }
@@ -1403,71 +1443,7 @@ function buildRenderersRuntime2(options) {
1403
1443
  `;
1404
1444
  }
1405
1445
  function buildUIComponentsRuntime() {
1406
- return `
1407
- // UI Components (Vendor)
1408
- (function() {
1409
- window.Card = function(props) {
1410
- var children = props.children;
1411
- var title = props.title;
1412
- var className = props.className || '';
1413
- return React.createElement('div', {
1414
- className: 'bg-white rounded-lg shadow border border-gray-200 overflow-hidden ' + className
1415
- }, [
1416
- title && React.createElement('div', {
1417
- key: 'header',
1418
- className: 'px-4 py-3 border-b border-gray-200 bg-gray-50'
1419
- }, React.createElement('h3', { className: 'text-sm font-medium text-gray-900' }, title)),
1420
- React.createElement('div', { key: 'body', className: 'p-4' }, children)
1421
- ]);
1422
- };
1423
-
1424
- window.Badge = function(props) {
1425
- var children = props.children;
1426
- var variant = props.variant || 'default';
1427
- var variantClasses = {
1428
- default: 'bg-gray-100 text-gray-800',
1429
- success: 'bg-green-100 text-green-800',
1430
- warning: 'bg-yellow-100 text-yellow-800',
1431
- error: 'bg-red-100 text-red-800',
1432
- info: 'bg-blue-100 text-blue-800'
1433
- };
1434
- return React.createElement('span', {
1435
- className: 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ' + (variantClasses[variant] || variantClasses.default)
1436
- }, children);
1437
- };
1438
-
1439
- window.Button = function(props) {
1440
- var children = props.children;
1441
- var variant = props.variant || 'primary';
1442
- var onClick = props.onClick;
1443
- var disabled = props.disabled;
1444
- var variantClasses = {
1445
- primary: 'bg-blue-600 text-white hover:bg-blue-700',
1446
- secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
1447
- outline: 'border border-gray-300 text-gray-700 hover:bg-gray-50',
1448
- danger: 'bg-red-600 text-white hover:bg-red-700'
1449
- };
1450
- return React.createElement('button', {
1451
- className: 'px-4 py-2 rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ' +
1452
- (disabled ? 'opacity-50 cursor-not-allowed ' : '') +
1453
- (variantClasses[variant] || variantClasses.primary),
1454
- onClick: onClick,
1455
- disabled: disabled
1456
- }, children);
1457
- };
1458
-
1459
- // Export to namespace
1460
- window.frontmcp_ui_namespaceObject = Object.assign({}, window.React || {}, {
1461
- useToolOutput: window.useToolOutput,
1462
- useToolInput: window.useToolInput,
1463
- useMcpBridgeContext: function() { return window.__frontmcp.context; },
1464
- useCallTool: function() { return function() { return Promise.resolve(null); }; },
1465
- Card: window.Card,
1466
- Badge: window.Badge,
1467
- Button: window.Button
1468
- });
1469
- })();
1470
- `;
1446
+ return buildBrowserUIComponents();
1471
1447
  }
1472
1448
  function buildUniversalAppRuntime2() {
1473
1449
  return `
@@ -1592,7 +1568,11 @@ function getCachedRuntime(options, config = {}) {
1592
1568
  }
1593
1569
  runtimeCache.delete(cacheKey);
1594
1570
  }
1595
- const vendorParts = [buildStoreRuntime2(), buildRequireShim()];
1571
+ const vendorParts = [];
1572
+ if (options.includeBridge) {
1573
+ vendorParts.push(getMCPBridgeScript());
1574
+ }
1575
+ vendorParts.push(buildStoreRuntime2(), buildRequireShim());
1596
1576
  if (options.cdnType === "umd" || options.includeMarkdown) {
1597
1577
  vendorParts.push(buildInlineMarkdownParser2(options));
1598
1578
  }
@@ -1631,7 +1611,7 @@ function buildAppTemplate() {
1631
1611
  return [buildCustomComponentsWrapper(), buildComponentWrapper(), buildDataInjectionWrapper()].join("\n");
1632
1612
  }
1633
1613
  function minifyScript(script) {
1634
- return script.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1614
+ return script.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/[^\n]*$/gm, "").replace(/\n\s*\n/g, "\n").replace(/^\s+/gm, "").trim();
1635
1615
  }
1636
1616
  function clearRuntimeCache() {
1637
1617
  runtimeCache.clear();
@@ -1652,7 +1632,46 @@ function getRuntimeCacheStats() {
1652
1632
  function buildAppScript(appTemplate, componentCode, dataInjection, customComponents = "") {
1653
1633
  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);
1654
1634
  }
1655
- function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
1635
+ var DEFAULT_OUTPUT_PLACEHOLDER = "__FRONTMCP_OUTPUT_PLACEHOLDER__";
1636
+ var DEFAULT_INPUT_PLACEHOLDER = "__FRONTMCP_INPUT_PLACEHOLDER__";
1637
+ function buildDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, options) {
1638
+ const buildMode = options?.buildMode ?? "static";
1639
+ const cdnType = options?.cdnType ?? "esm";
1640
+ switch (buildMode) {
1641
+ case "dynamic":
1642
+ return buildDynamicDataInjectionCode(
1643
+ toolName,
1644
+ input,
1645
+ output,
1646
+ structuredContent,
1647
+ contentType,
1648
+ source,
1649
+ hasComponent,
1650
+ cdnType,
1651
+ options?.dynamicOptions
1652
+ );
1653
+ case "hybrid":
1654
+ return buildHybridDataInjectionCode(
1655
+ toolName,
1656
+ structuredContent,
1657
+ contentType,
1658
+ source,
1659
+ hasComponent,
1660
+ options?.hybridOptions
1661
+ );
1662
+ default:
1663
+ return buildStaticDataInjectionCode(
1664
+ toolName,
1665
+ input,
1666
+ output,
1667
+ structuredContent,
1668
+ contentType,
1669
+ source,
1670
+ hasComponent
1671
+ );
1672
+ }
1673
+ }
1674
+ function buildStaticDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent) {
1656
1675
  const safeJson = (value) => {
1657
1676
  try {
1658
1677
  return JSON.stringify(value);
@@ -1662,6 +1681,7 @@ function buildDataInjectionCode(toolName, input, output, structuredContent, cont
1662
1681
  };
1663
1682
  if (hasComponent) {
1664
1683
  return `
1684
+ // Static Mode - Data baked at build time
1665
1685
  window.__frontmcp.setState({
1666
1686
  toolName: ${safeJson(toolName)},
1667
1687
  input: ${safeJson(input ?? null)},
@@ -1676,6 +1696,7 @@ function buildDataInjectionCode(toolName, input, output, structuredContent, cont
1676
1696
  });`;
1677
1697
  }
1678
1698
  return `
1699
+ // Static Mode - Data baked at build time
1679
1700
  window.__frontmcp.setState({
1680
1701
  toolName: ${safeJson(toolName)},
1681
1702
  input: ${safeJson(input ?? null)},
@@ -1689,6 +1710,181 @@ function buildDataInjectionCode(toolName, input, output, structuredContent, cont
1689
1710
  error: null
1690
1711
  });`;
1691
1712
  }
1713
+ function buildDynamicDataInjectionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, cdnType, dynamicOptions) {
1714
+ if (cdnType === "umd") {
1715
+ return buildDynamicWithPlaceholdersCode(
1716
+ toolName,
1717
+ structuredContent,
1718
+ contentType,
1719
+ source,
1720
+ hasComponent,
1721
+ dynamicOptions
1722
+ );
1723
+ }
1724
+ return buildDynamicWithSubscriptionCode(
1725
+ toolName,
1726
+ input,
1727
+ output,
1728
+ structuredContent,
1729
+ contentType,
1730
+ source,
1731
+ hasComponent,
1732
+ dynamicOptions
1733
+ );
1734
+ }
1735
+ function buildDynamicWithPlaceholdersCode(toolName, structuredContent, contentType, source, hasComponent, dynamicOptions) {
1736
+ const safeJson = (value) => {
1737
+ try {
1738
+ return JSON.stringify(value);
1739
+ } catch {
1740
+ return "null";
1741
+ }
1742
+ };
1743
+ const outputPlaceholder = DEFAULT_OUTPUT_PLACEHOLDER;
1744
+ const inputPlaceholder = DEFAULT_INPUT_PLACEHOLDER;
1745
+ const includeInitialData = dynamicOptions?.includeInitialData ?? true;
1746
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1747
+ return `
1748
+ // Dynamic Mode - Placeholder-based for non-OpenAI platforms
1749
+ var __outputRaw = "${outputPlaceholder}";
1750
+ var __inputRaw = "${inputPlaceholder}";
1751
+ var __output = null;
1752
+ var __input = null;
1753
+ var __error = null;
1754
+ var __outputNotReplaced = false;
1755
+ var __includeInitialData = ${includeInitialData};
1756
+
1757
+ // Parse output placeholder
1758
+ if (typeof __outputRaw === 'string' && __outputRaw !== "${outputPlaceholder}") {
1759
+ try { __output = JSON.parse(__outputRaw); } catch (e) {
1760
+ console.warn('[FrontMCP] Failed to parse output:', e);
1761
+ __error = 'Failed to parse output data';
1762
+ }
1763
+ } else if (__outputRaw === "${outputPlaceholder}") {
1764
+ __outputNotReplaced = true;
1765
+ }
1766
+
1767
+ // Parse input placeholder
1768
+ if (typeof __inputRaw === 'string' && __inputRaw !== "${inputPlaceholder}") {
1769
+ try { __input = JSON.parse(__inputRaw); } catch (e) { console.warn('[FrontMCP] Failed to parse input:', e); }
1770
+ }
1771
+
1772
+ // Handle placeholder not replaced - show error if expecting initial data
1773
+ if (__outputNotReplaced && __includeInitialData) {
1774
+ __error = 'No data provided. The output placeholder was not replaced.';
1775
+ }
1776
+
1777
+ window.__frontmcp.setState({
1778
+ toolName: ${safeJson(toolName)},
1779
+ input: __input,
1780
+ output: __output,
1781
+ structuredContent: ${safeJson(structuredContent ?? null)},
1782
+ ${contentBlock},
1783
+ loading: !__includeInitialData && __output === null && !__error,
1784
+ error: __error
1785
+ });`;
1786
+ }
1787
+ function buildDynamicWithSubscriptionCode(toolName, input, output, structuredContent, contentType, source, hasComponent, dynamicOptions) {
1788
+ const safeJson = (value) => {
1789
+ try {
1790
+ return JSON.stringify(value);
1791
+ } catch {
1792
+ return "null";
1793
+ }
1794
+ };
1795
+ const includeInitialData = dynamicOptions?.includeInitialData ?? true;
1796
+ const subscribeToUpdates = dynamicOptions?.subscribeToUpdates ?? true;
1797
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1798
+ const initialState = includeInitialData ? `{
1799
+ toolName: ${safeJson(toolName)},
1800
+ input: ${safeJson(input ?? null)},
1801
+ output: ${safeJson(output ?? null)},
1802
+ structuredContent: ${safeJson(structuredContent ?? null)},
1803
+ ${contentBlock},
1804
+ loading: false,
1805
+ error: null
1806
+ }` : `{
1807
+ toolName: ${safeJson(toolName)},
1808
+ input: ${safeJson(input ?? null)},
1809
+ output: null,
1810
+ structuredContent: ${safeJson(structuredContent ?? null)},
1811
+ ${contentBlock},
1812
+ loading: true,
1813
+ error: null
1814
+ }`;
1815
+ const subscriptionBlock = subscribeToUpdates ? `
1816
+ // Subscribe to platform tool result events
1817
+ (function() {
1818
+ function subscribeToUpdates() {
1819
+ if (window.openai && window.openai.canvas && window.openai.canvas.onToolResult) {
1820
+ window.openai.canvas.onToolResult(function(result) {
1821
+ window.__frontmcp.updateOutput(result);
1822
+ window.dispatchEvent(new CustomEvent('frontmcp:toolResult', { detail: result }));
1823
+ });
1824
+ }
1825
+ }
1826
+ if (document.readyState === 'loading') {
1827
+ document.addEventListener('DOMContentLoaded', subscribeToUpdates);
1828
+ } else {
1829
+ subscribeToUpdates();
1830
+ }
1831
+ })();` : "";
1832
+ return `
1833
+ // Dynamic Mode - OpenAI Subscription
1834
+ window.__frontmcp.setState(${initialState});
1835
+ ${subscriptionBlock}`;
1836
+ }
1837
+ function buildHybridDataInjectionCode(toolName, structuredContent, contentType, source, hasComponent, hybridOptions) {
1838
+ const safeJson = (value) => {
1839
+ try {
1840
+ return JSON.stringify(value);
1841
+ } catch {
1842
+ return "null";
1843
+ }
1844
+ };
1845
+ const outputPlaceholder = hybridOptions?.placeholder ?? DEFAULT_OUTPUT_PLACEHOLDER;
1846
+ const inputPlaceholder = hybridOptions?.inputPlaceholder ?? DEFAULT_INPUT_PLACEHOLDER;
1847
+ const contentBlock = hasComponent ? `content: { type: 'react', source: window.__frontmcp_component }` : `content: { type: ${safeJson(contentType)}, source: ${safeJson(source)} }`;
1848
+ return `
1849
+ // Hybrid Mode - Placeholders replaced at runtime
1850
+ var __outputRaw = "${outputPlaceholder}";
1851
+ var __inputRaw = "${inputPlaceholder}";
1852
+ var __output = null;
1853
+ var __input = null;
1854
+ var __error = null;
1855
+ var __outputNotReplaced = false;
1856
+
1857
+ // Parse output placeholder
1858
+ if (typeof __outputRaw === 'string' && __outputRaw !== "${outputPlaceholder}") {
1859
+ try { __output = JSON.parse(__outputRaw); } catch (e) {
1860
+ console.warn('[FrontMCP] Failed to parse output:', e);
1861
+ __error = 'Failed to parse output data';
1862
+ }
1863
+ } else if (__outputRaw === "${outputPlaceholder}") {
1864
+ // Placeholder not replaced - no data was injected
1865
+ __outputNotReplaced = true;
1866
+ }
1867
+
1868
+ // Parse input placeholder
1869
+ if (typeof __inputRaw === 'string' && __inputRaw !== "${inputPlaceholder}") {
1870
+ try { __input = JSON.parse(__inputRaw); } catch (e) { console.warn('[FrontMCP] Failed to parse input:', e); }
1871
+ }
1872
+
1873
+ // Set error if output placeholder was not replaced (no data provided)
1874
+ if (__outputNotReplaced) {
1875
+ __error = 'No data provided. The output placeholder was not replaced.';
1876
+ }
1877
+
1878
+ window.__frontmcp.setState({
1879
+ toolName: ${safeJson(toolName)},
1880
+ input: __input,
1881
+ output: __output,
1882
+ structuredContent: ${safeJson(structuredContent ?? null)},
1883
+ ${contentBlock},
1884
+ loading: false,
1885
+ error: __error
1886
+ });`;
1887
+ }
1692
1888
  function buildComponentCode(transpiledCode) {
1693
1889
  return `
1694
1890
  // CommonJS module shim
package/index.d.ts CHANGED
@@ -30,11 +30,8 @@
30
30
  */
31
31
  export * from './components';
32
32
  export * from './layouts';
33
- export * from './pages';
34
- export * from './widgets';
35
33
  export { type PlatformAdapter, type AdapterCapabilities, type BridgeConfig, FrontMcpBridge, createBridge, AdapterRegistry, defaultRegistry, registerAdapter, generateBridgeIIFE, generatePlatformBundle, UNIVERSAL_BRIDGE_SCRIPT, BRIDGE_SCRIPT_TAGS, } from './bridge';
36
34
  export { registerAllComponents, registerFmcpButton, registerFmcpCard, registerFmcpAlert, registerFmcpBadge, registerFmcpInput, registerFmcpSelect, FmcpButton, FmcpCard, FmcpAlert, FmcpBadge, FmcpInput, FmcpSelect, FmcpElement, } from './web-components';
37
35
  export * from './react';
38
- export * from './render';
39
- export { ReactRenderer, reactRenderer, buildHydrationScript, ReactRendererAdapter, createReactAdapter, loadReactAdapter, } from './renderers';
36
+ export { ReactRenderer, reactRenderer, ReactRendererAdapter, createReactAdapter, loadReactAdapter } from './renderers';
40
37
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,cAAc,cAAc,CAAC;AAK7B,cAAc,WAAW,CAAC;AAK1B,cAAc,SAAS,CAAC;AAKxB,cAAc,WAAW,CAAC;AAK1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,cAAc,EACd,YAAY,EAEZ,eAAe,EACf,eAAe,EACf,eAAe,EAEf,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAEL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAElB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EAEV,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAK1B,cAAc,SAAS,CAAC;AAKxB,cAAc,UAAU,CAAC;AAKzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,cAAc,cAAc,CAAC;AAK7B,cAAc,WAAW,CAAC;AAK1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,cAAc,EACd,YAAY,EAEZ,eAAe,EACf,eAAe,EACf,eAAe,EAEf,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAEL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAElB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EAEV,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAK1B,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}